Commit Graph

393 Commits

Author SHA1 Message Date
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
Jonas Maebe
98a230d20f * don't call swapendian for shortint (it's 1 byte -> upcast to word and then
swapped, which is wrong)

git-svn-id: trunk@25949 -
2013-11-06 09:44:29 +00:00
svenbarth
d908dbeec1 Fix for Mantis #25215.
compiler/scanner.pas, tscannerfile.readtoken:
  * after trying to read a _INTCONST check whether a valid first character for an identifier follows and give a syntax error if that is not the case

+ added test

git-svn-id: trunk@25835 -
2013-10-20 12:15:49 +00:00
paul
d801548604 compiler: support also XOR expressions in macro expressions
git-svn-id: trunk@25583 -
2013-09-27 00:28:15 +00:00
nickysn
52a5ffc386 * use apptype to indicate that the target is a DOS .COM file, instead of introducing a new field in tsettings (as suggested by Sven)
git-svn-id: trunk@25544 -
2013-09-24 12:13:47 +00:00
svenbarth
9d48bc0baf Implement cross unit type overloading of generics. This fixes the regression introduced with revision 25498.
symtable.pas:
  + add new tsymbol_search_flag type which can be passed to various searchsym* routines
  + add support to not call "addsymref"
  + add new searchsym_with_flags function that calls searchsym_maybe_with_symoption
  * adjust searchsym_maybe_with_symoption, searchsym_in_class & searchsym_in_helper to use new flag type instead of Boolean arguments
  * adjust searchsym & searchsym_with_symoption which call the modified functions
nutils.pas, handle_staticfield_access:
  * adjust searchsym_in_class call
pexpr.pas, handle_factor_typenode, postfixoperators, factor:
  * adjust searchsym_in_helper and searchsym_in_class calls
pinline.pas, new_function:
  * adjust searchsym_in_class call
scanner.pas, try_consume_nestedsym:
  * adjust searchsym_in_class call
fmodule.pas, tmodule:
  + add genericdummysyms field which is a TFPHashObjectList that contains TFPObjectList instances per generic dummy that in turn contains tgenericdummysyms instances
pgenutil.pas:
  + add function split_generic_name to split a generic name into non-generic name and count value of type parameters
  + add function resolve_generic_dummysym which tries to use the new genericdummysyms field to find the real symbol of a dummy sym
  * generate_specialization: adjust searchsym_in_class call
  * specialization_init/specialization_done: save/restore genericdummysyms of module
symdef.pas, tdefawaresymtablestack:
  + add new intermediate method pushcommon which is used by both push and pushafter
  + add new intermediate method remove_helpers_and_generics (which calls remove_generics and remove_helpers if necessary)
  * rename removehelpers to remove_helpers
  * rename addhelpers to add_helpers_and_generics and extend it to correctly fill current_module.genericdummysyms
  * call remove_helpers_and_generics from pop instead of remove_helpers
ptype.pas, single_type, read_named_type.expr_type, read_named_type:
  * try to resolve symbols with sp_generic_dummy with resolve_generic_dummysym

+ added test

git-svn-id: trunk@25519 -
2013-09-18 14:28:46 +00:00
paul
73dab82a7f compiler: refactor preproc_substitutedtoken - pass the searchstr into it
git-svn-id: trunk@25475 -
2013-09-13 01:19:19 +00:00
paul
e42e9bb677 compiler: support ORD() intrinsic in preprocessor expressions
git-svn-id: trunk@25471 -
2013-09-12 12:52:07 +00:00
paul
974aeb5573 compiler: support MOD, DIV, SHR, SHL in preprocessor expressions
git-svn-id: trunk@25469 -
2013-09-12 11:22:59 +00:00
paul
cc37b19bb2 compiler: allow 1 and 0 to be used as Booleans in preprocessor expressions
git-svn-id: trunk@25467 -
2013-09-12 09:30:48 +00:00
paul
06e7808f64 compiler: return short evaluation of preprocessor expressions with AND or OR. This fixes univint package compilation.
git-svn-id: trunk@25466 -
2013-09-12 09:06:13 +00:00
paul
038b7746fb compiler: implement preprocessor expressions (fixes mantis #0010671)
- move operator_levels to topens.pas - it is used from 2 units now
  - implement pexpr like sub_expr for preprocessor expressions
  - implement +,-,*,/ expressions for the moment
  * move OR, AND, IN implemenetation to the new logic

git-svn-id: trunk@25465 -
2013-09-12 08:35:24 +00:00
paul
6eba4226b6 compiler: move OR and AND preprocessor evaluation to texprvalue.evaluate
git-svn-id: trunk@25464 -
2013-09-12 06:59:12 +00:00
paul
7ecaaf0ef8 compiler: further improve preprocessor evaluator:
* support TRUE,FALSE for all modes
  * refactor texprvalue.evaluate to support arithmetic expressions and implement them here
  * simplify read_expr and read_factor code

git-svn-id: trunk@25463 -
2013-09-12 06:01:49 +00:00
paul
cac09f9df1 compiler: better handling of '$','%','&' in macros
git-svn-id: trunk@25462 -
2013-09-12 02:33:02 +00:00
paul
0eb4244a67 compiler: implement compile-time expression with float numbers (issue #0010670), better handling of integer expressions too
git-svn-id: trunk@25461 -
2013-09-12 01:59:26 +00:00
paul
eff0403fc1 compiler: reimplement handling of compile time variables - they are stored like tconstsym now instead of string. Expressions are evaluated more accurate now.
git-svn-id: trunk@25460 -
2013-09-12 00:38:17 +00:00
paul
8d526e9b07 compiler: add a check for srsym <> nil since try_consume_unitsym may change srsym to nil, better error message
git-svn-id: trunk@25423 -
2013-09-05 08:39:10 +00:00
paul
3f2e62874b compiler: handle unit, namespace and class/record/object prefixes before identifiers while parsing {$IF ...} expressions (fixes mantis #0020996)
git-svn-id: trunk@25422 -
2013-09-05 07:05:19 +00:00
florian
0e41df598e * merge i8086 branch by Nikolay Nikolov
git-svn-id: trunk@24324 -
2013-04-25 20:23:51 +00:00
florian
7ac7d8a4b6 + define UNICODE as well as FPC_UNICODESTRINGS
git-svn-id: trunk@24214 -
2013-04-09 13:05:29 +00:00
Jonas Maebe
8b7071c8e8 * fixed recording generics token line info on big endian systems
git-svn-id: trunk@23926 -
2013-03-18 13:29:15 +00:00
florian
d4613fe961 * update init_settings.setalloc in SetCompileMode if changeinit is set
git-svn-id: trunk@23898 -
2013-03-17 16:42:34 +00:00
florian
20a534e63f * fixed code which causes range check errors when compiled with -Cr
git-svn-id: trunk@23889 -
2013-03-17 14:24:50 +00:00
nickysn
7d212a7e79 * default to intel assembler for delphi/tp7 modes also on i8086
git-svn-id: branches/i8086@23838 -
2013-03-14 22:19:10 +00:00
paul
3682fddc49 compiler: minor optimization of tscannerfile.recordtoken
git-svn-id: trunk@23798 -
2013-03-12 01:32:07 +00:00
paul
2a3618fb6c compiler: set apptype using new SetAppType routine, add 'CONSOLE' define for console apptype.
git-svn-id: trunk@23603 -
2013-02-13 03:21:03 +00:00
paul
8db6118965 compiler: define FPC_UNICODESTRINGS when UnicodeString is a default string type (for issue #0023861)
git-svn-id: trunk@23601 -
2013-02-13 01:02:40 +00:00
svenbarth
d49b4043ab Implement DECLARED() for generic symbols. This fixes Mantis #21829 . The syntax is SomeGenericType<> for a generic with only one type parameter and SomeGeneric<,[,]*> for a generic with more than one type parameter. Spaces between the commas or brackets are allowed.
scanner.pas, parse_compiler_expr.read_factor:
  + allow "<>" after "declared" (handle "<>" operator specially)
  + count "," to get correct amount of type parameters
  + check together with the count string for symbols 
  + correctly handle dummy symbols

+ added tests

git-svn-id: trunk@23544 -
2013-01-30 16:10:15 +00:00
svenbarth
632db2229f Fix for Mantis #23700 .
scanner.pas, parse_compiler_expr.read_factor:
  * initialize result value

git-svn-id: trunk@23454 -
2013-01-20 11:21:20 +00:00
svenbarth
b5827ce363 Move the handling of "misstyled" floating point constants like "2." or "2.e10" from the scanner to the parser. This way type helpers calls for integer constants can be parsed correctly in the future.
Note: the error messages for incorrect "misstyled" floating point numbers (e.g. "2e10foo") have changed because of this.

scanner.pas, tscannerfile.readtoken:
  instead of tokenizing "2.", "2.e10", "2.e+10" and "2.e-10" as "_REALNUMBER" tokenize them as "_INTCONST _POINT", "_INTCONST _POINT _ID", "_INTCONST _POINT _ID _PLUS _INTCONST" "_INTCONST _POINT _ID _PLUS _INTCONST"; tokenizing of normal floating constants is not changed

pexpr.pas:
  factor: 
    * extract the code for creating a new constant floating point from "factor" into a new function "real_const_node_from_pattern"
    + allow the parsing of postfixoperators for integer constants if a "." is encountered
  + postfixoperators: check for a "misstyled" floating point number if an ordinal const (not an enum and not a boolean) is encountered (the code is already partially prepared for type helper support)
  
+ Added tests

git-svn-id: trunk@23356 -
2013-01-10 16:23:00 +00:00
florian
f25f44605e - get rid of m_all, use a set instead for tokens, this allows to disable/enable tokens depending on the language mode
git-svn-id: trunk@22506 -
2012-09-30 21:03:35 +00:00
paul
57da93dd11 compiler: don't reject utf-8 codepage as default althought it is not present in mapping tables
git-svn-id: trunk@22409 -
2012-09-17 02:24:56 +00:00
Jonas Maebe
07ebc51b6c * always store generics token streams in little endian, so we don't have to
keep a separate field for each tstoreddef that records whether the
    endianness needs to be swapped

git-svn-id: trunk@21914 -
2012-07-15 16:09:14 +00:00
svenbarth
f90e686be2 Always try to present file/line information for generics even if no source is available or the unit was compiled as release unit. This allows IDE like Lazarus to correctly navigate to an error or warning even if the unit containing the generic was compiled as a release unit.
* pscanner.pas, tscannerfile.replaytoken: remove the checks for "sources_avail" and always update the read file/line information 
* fppu.pas, tppumodule.readsourcefiles: always load at least the filenames which were used when compiling the unit from the ppu file, so that file/line information will be correctly shown, but don't touch the "sources_avail" flag of the tppumodule

git-svn-id: trunk@21657 -
2012-06-20 09:01:28 +00:00
svenbarth
e0b41141d2 "SizeInt" inside the compiler references the "size of an int" on the Host platform. What we want for writing size information in PPUs for Generics is "ASizeInt" which is the "size of an int" of the target platform. This fixes Mantis #20947.
* pscanner.pas: change SizeInt to ASizeInt for tokenreadsizeint and tokenwritesizeint and change necessary other locations for record- and replaytokenbuffers
+ Added a test in the hope that some test-platforms do cross platform (e.g. win32 => win64) compilation.

git-svn-id: trunk@21651 -
2012-06-19 08:47:30 +00:00
pierre
261538f9c2 Fix bug report 22265
git-svn-id: trunk@21609 -
2012-06-14 14:00:44 +00:00
pierre
41248ea4f7 Hopefully correct fix for ReplayToken TSettings record writes
git-svn-id: trunk@21605 -
2012-06-14 10:14:24 +00:00
pierre
1d4862f3c1 * Remove obsolete size check leading to failure for generics tests
git-svn-id: trunk@21604 -
2012-06-14 07:28:55 +00:00
pierre
d67d1abcba * Use field by field write of current_settings for replaytoken and remove packed attribute for tsettings type
git-svn-id: trunk@21594 -
2012-06-13 21:51:59 +00:00
paul
d79eee8ed1 compiler: write a warning if unit should be compiled with built-in system codepage for ansistring constants but this codepage is not known by the compiler
git-svn-id: trunk@21269 -
2012-05-10 01:24:18 +00:00
Jonas Maebe
50d2fa7134 * after changing a modeswitch, only change related module/localswitches that
depend on the modeswitch that was just changed (so that e.g. changing
    the nested procvars setting has no effect on the state of $h+/$h-)
    (mantis #21951)

git-svn-id: trunk@21247 -
2012-05-06 14:56:49 +00:00
paul
aad9294c27 compiler: when explicit codepage modeswitch is installed and compiler has no codepage map for the DefaultSystemCodepage use default compiler codepage
git-svn-id: trunk@21223 -
2012-05-04 06:09:35 +00:00
Jonas Maebe
14cfe770a4 * replaced most (if not all) remaining fields/parameters in the compiler
that deal with paths/filenames with TPathStr (= ansistring) to prevent
    cutting off long paths (no change in speed when compiling the compiler,
    1% extra memory usage)

git-svn-id: trunk@21120 -
2012-04-29 17:36:23 +00:00
Jonas Maebe
aee5380ae0 * merged trunk up to r20882
o support for the new codepage-aware ansistrings in the jvm branch
   o empty ansistrings are now always represented by a nil pointer rather than
     by an empty string, because an empty string also has a code page which
     can confuse code (although this will make ansistrings harder to use
     in Java code)
   o more string helpers code shared between the general and jvm rtl
   o support for indexbyte/word in the jvm rtl (warning: first parameter
     is an open array rather than an untyped parameter there, so
     indexchar(pcharvar^,10,0) will be equivalent to
     indexchar[pcharvar^],10,0) there, which is different from what is
     intended; changing it to an untyped parameter wouldn't help though)
   o default() support is not yet complete
   o calling fpcres is currently broken due to limitations in
     sysutils.executeprocess() regarding handling unix quoting and
     the compiler using the same command lines for scripts and directly
     calling external programs
   o compiling the Java compiler currently requires adding ALLOW_WARNINGS=1
     to the make command line

git-svn-id: branches/jvmbackend@20887 -
2012-04-15 15:54:10 +00:00
pierre
1c27730c8c * Give debug information once for each conditional directive
git-svn-id: trunk@20648 -
2012-03-28 14:09:04 +00:00
florian
99b0421193 + patch by Seth Grover to support line number macro returning a numerical number, resolves #21372
git-svn-id: trunk@20608 -
2012-03-23 20:35:42 +00:00
Jonas Maebe
a6a43c71ec * give an error message when including a file starting with an UTF-8 BOM
in a compilation module parsed using a different code page, because this
    changes the default ansistring type and {$codepage xxx} is also not
    allowed in the middle of a unit (mantis #21445)

git-svn-id: trunk@20488 -
2012-03-09 22:50:14 +00:00
florian
4a79262728 * make asciinr string long enough for binary char constants as pointed out by Matti Kronman, resolves #20821
git-svn-id: trunk@19782 -
2011-12-08 22:04:32 +00:00
paul
c6ca9e5091 compiler:
- add helper function getansistringcodepage which returns explicitly set codepage or 0 in other case
  - add helper function getansistringdef which return a def with explicitly set codepage or cansistringtype in other case
  - change tstoreddef.createnai constructor to allow set codepage in constructor
  - don't convert string constants to rawbytestring. if string constant already has a codepage - preserve it or convert to ansistring codepage (delphi compatible)
  - don't perform string conversion from ansistring to strings with explicitly set codepage (by directive or by compiler switch) and vice versa (delphi compatible)
  + test which covers most of the cases

git-svn-id: trunk@19510 -
2011-10-19 02:45:52 +00:00