Commit Graph

358 Commits

Author SHA1 Message Date
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
florian
73a084d662 * fixes bootstrapping with 2.6.0
git-svn-id: trunk@19491 -
2011-10-15 12:42:33 +00:00
paul
21ac5dfb3b compiler: output ansistring constants in explicit codepage if codepage is explicitly defined using either $codepage directive or compiler switch or for SystemCodepage modeswitch
git-svn-id: trunk@19462 -
2011-10-11 08:58:56 +00:00
paul
a99ffb3097 compiler: apply patches from Inoussa and Jonas:
defcmp: Address code paged' string type comparison taking care of the code page
  ncnv: Remove un-needed code page comparison to CP_UTF8, some fixes regarding shortstrings and wide char/string 
  ncon: For the case of tstringconstnode.changestringtype (ncon.pas) where the code page are of CP_NONE or 0 no translation is done as :
    * CP_NONE is compatible to all
    * For 0 the raw bytes are just copied.
 My changes:
  - change ascii2unicode to allow pass source codepage, 
  - convert in both cases when source or destination is UTF8

git-svn-id: trunk@19457 -
2011-10-11 01:21:07 +00:00
paul
6f185f2184 compiler: replace {$ifdef FPC_FULLVERSION<20700} with {$ifdef VER2_4} for including ccharset as in other compiler places
git-svn-id: trunk@19284 -
2011-09-29 14:15:09 +00:00
florian
a6d01c09aa * make compiler compilable with 2.4.4 rtl
git-svn-id: trunk@19269 -
2011-09-28 18:54:32 +00:00
florian
d7f7a9bb76 * patch by Alexander Shishkin to clean up $ifopt usage by $push/$pop, resolves #20346
git-svn-id: trunk@19256 -
2011-09-27 20:22:40 +00:00
Jonas Maebe
cf47b8d422 * fixed all known memory leaks in the code added for the JVM port
git-svn-id: branches/jvmbackend@19248 -
2011-09-26 19:31:34 +00:00
pierre
10586b19c3 * Reading tsettings field by field
git-svn-id: trunk@19167 -
2011-09-21 15:34:16 +00:00
paul
828367bebd compiler:
- return default compiler codepage to 8859-1
  - emit ansistring constants in CP_NONE by default
  - add new modeswitch systemcodepage which sets default compiler codepage to system and emits ansistring constants with systemcodepage as delphi do
  - add new mode DelphiUnicode with has the same switches as delphi mode + systemcodepage switch. Later it will also have string = unicodestring by default.

git-svn-id: trunk@19165 -
2011-09-21 01:23:42 +00:00
paul
4d3da666db compiler: replace string codepage comparison to numeric. store codepage as number in current settings
git-svn-id: trunk@19144 -
2011-09-19 00:48:43 +00:00
paul
f3ebaab222 merge r19075 from cpstrnew branch by paul:
compiler: partly revert r17434 because of a test regression. Also this is delphi compatible (although delphi does not know a {$codepage} directive)

git-svn-id: trunk@19127 -
2011-09-17 14:26:30 +00:00
paul
1db610ecbd merge r17434 from cpstrnew branch by michael:
* Patch from Inoussa to fix constant strings with codepage

git-svn-id: trunk@19109 -
2011-09-17 13:19:59 +00:00
pierre
47f39748f6 Handle FileIndex/Line/Column for change_nedian in token buffer for generics
git-svn-id: trunk@19014 -
2011-09-07 16:27:33 +00:00
pierre
57f3f0a82b scanner unit:
treplaystack class: added change_endian boolean field
  treplaystack.create added achange_endian parameter
  tscannerfile class: added tokenbuf_change_endian boolean field
  readsizeint method: use tokenbuf_change_endian to maybe swap sizeint
  startreplaytokens method: added achange_endian field
  psub and ptype units:
  adapt to tscannerfile.startreplaytokens change above.

git-svn-id: trunk@19012 -
2011-09-07 13:13:15 +00:00
pierre
b526bb4dfa * Fix failures introduced by rev 18975
git-svn-id: trunk@18976 -
2011-09-05 07:51:22 +00:00
pierre
68d27263e7 Try to improve RecordTokenBuf with respect to PPU reading
git-svn-id: trunk@18975 -
2011-09-04 22:43:41 +00:00
pierre
637a4671d9 Fix messages to tokenbuufer writing to zvoid problems with PPU
git-svn-id: trunk@18957 -
2011-09-03 17:38:53 +00:00
Jonas Maebe
28c20cfc5e * the default string type for the JVM target is no longer automatically
unicodestring = java.lang.String. The reason this was the default in
    the past is that this was the first string type that was implemented,
    and without it being the default most code involving string operations
    would fail. Now the default strings types are the same as for other
    targets
  + new {$modeswitch unicodestrings} directive, that when activated
    *together* with {$h+},
   1) changes char into an alias for widechar
   2) changes string into an alias for unicodestring
   3) changes the preferred string evaluation type (in case of uncertainty)
      to unicodestring
    {$modeswitch unicodestrings} with {$h-} does not change anything at all
    regarding the string type (it still changes the char type)
  + new uuchar unit that redefines char as widechar, and which is automatically
    included by the compiler if {$modeswitch unicodestrings} is enabled

git-svn-id: branches/jvmbackend@18781 -
2011-08-20 08:35:47 +00:00
Jonas Maebe
e534a17c01 - removed unused scanner.tscannerstate, inserttext_begin and inserttext_end
(leftovers from the initial symcreat implementations that didn't work)

git-svn-id: branches/jvmbackend@18637 -
2011-08-20 08:20:13 +00:00
Jonas Maebe
019ca93a04 * symcreat functionality to use the parser from inside the compiler for
artificially generated stuff rather than directly working with defs/syms
   problems
    o scanner state saving/restoring, and avoiding problems in case of
      errors in the injected strings
    o in case of the actual application (adding overriding constructors):
      the parameters may be of types not visible in the current unit to
      newly written code -> can't just use the scanner...

git-svn-id: branches/jvmbackend@18427 -
2011-08-20 07:58:44 +00:00
Jonas Maebe
7200245337 + cs_unicodestrings global switch to indicate that the default string type
is unicodestring (does *not* change the type of "char" to "unicodechar"
    (yet)). Not yet (un)selectable via a directive.
  + systems_default_unicodestring set containing systems on which the
    default string type is unicodestring

git-svn-id: branches/jvmbackend@18415 -
2011-08-20 07:57:45 +00:00
Jonas Maebe
37b5c061e3 + support for "final" fields in *external* (Java and other) classes, enabled
via {$modeswitch finalfields} (on by default on the JVM target). The
    meaning is the same as in Java: a final (class) field can only be set
    in a (class) constructor of the class it's defined in, and can only be
    written once there (and *must* be set there). They are currently only
    supported for external classes since that basically turns them into
    constants, since for non-external classes we need full dataflow analysis
  o refactored pdecobj.parse_object_members() a bit in the process to reduce
    the amount of repetition (which would have been further increased for
    the support for final fields)
  o made error message about "wrong use of absolute" for fields etc generic,
    so it gives a proper error depending on which token was used (it had
    to be made generic for "final" support, but already was used for other
    things that were wrongly reported as "absolute" misusages)

git-svn-id: branches/jvmbackend@18398 -
2011-08-20 07:56:18 +00:00
Jonas Maebe
baf2a3f1fb * fixed copy/paste error that didn't disable default inline support when
switching from a mode that has it to a mode that doesn't have it (which
    meant that all modes had it, since the default FPC mode has it)
  * added default inline support to mode macpas to minimize breaking existing
    code due to this switch (only TP and ISO modes now don't have it by
    default)

git-svn-id: trunk@18265 -
2011-08-18 18:12:09 +00:00
florian
d19d8de8fe * packed column writing/reading for token recorder, reduces size of fgl.ppu by approx. 10%
git-svn-id: trunk@17512 -
2011-05-20 17:43:11 +00:00
florian
7d9c4a97ce + compression of tokens in token recorder
git-svn-id: trunk@17508 -
2011-05-19 20:32:19 +00:00
florian
41c18adaf4 * patch by Sven Barth, handle idtoken correctly in the token recorder, resolves #19277
git-svn-id: trunk@17506 -
2011-05-19 19:31:08 +00:00
florian
13285ab264 o several strings changed into ansistrings, resolves #19318, no compilation speed degrations measurable
* TCmdStr changed into an ansistring
 * command line parameter handling uses now ansistrings
 * message handling parameters are now ansistrings

git-svn-id: trunk@17469 -
2011-05-15 14:53:31 +00:00
paul
86d3e41442 compiler: replace MODESWTICH POINTERARITHMETICS with $POINTERMATH directive, disable pointer arithmetic in delphi mode by default (compatible with delphi), enable pointer arithmetic in fpc/objfpc modes as they had it enabled by default before, add has_pointer_math field to tpointerdef to allow pointer arithmetic with such pointer even if pointer math mode is off (delphi compatible) + tests
git-svn-id: trunk@16651 -
2010-12-29 03:24:28 +00:00
paul
77fa5b7fb9 compiler: read and write full token size instead of 1 byte because TToken has more than 255 elements now
git-svn-id: trunk@16642 -
2010-12-26 15:15:20 +00:00
paul
92d6503704 compiler: rename _EQUAL token to _EQ to prevent problems with adding delphi operator names which contains "EQUAL" name, also rename _UNEQUAL to _NE for consistency
git-svn-id: trunk@16608 -
2010-12-22 02:01:40 +00:00
florian
dce3405c66 * reset lookahead char as well when resetting the scanner, resolves #17688
git-svn-id: trunk@16216 -
2010-10-24 21:26:30 +00:00
florian
ced4f95c56 + introduce iso mode
git-svn-id: trunk@15677 -
2010-07-31 20:38:42 +00:00
Jonas Maebe
835899524b + support for Objective-Pascal for-in loops ("fast enumerations")
+ {$modeswitch objectivec2}, which is required before you can use
    Objective-C 2.0 features (such as the above). It automatically
    also implies {$modeswitch objectivec1}
  + genloadfield() helper to load a field of a node representing
    a record/object/class

git-svn-id: trunk@15460 -
2010-06-20 12:38:45 +00:00
paul
1ef53ca590 compiler: remove unused variables (reduce hints)
git-svn-id: trunk@15093 -
2010-03-30 04:30:41 +00:00
Jonas Maebe
87c9773ac0 + also support & to escape identifiers (and for octal notation) in Delplhi
mode (patch by Blaise Thorn, mantis #15930)

git-svn-id: trunk@15031 -
2010-03-21 23:33:44 +00:00