Commit Graph

396 Commits

Author SHA1 Message Date
svenbarth
5bb121e91c Add a mechanism to keep track of assembler symbols that either publicly provided by a unit or used by a unit and that are not really baked by a Pascal symbol (e.g. public function aliases, RTTI & VMT symbol).
This basically revives the globalasmsym entry of the PPU though it feeds to different lists, one for the public (exported) symbols and one for the external (imported) symbols. Also the list of symbols is much smaller as it would be if all symbols would be dumped in there.

git-svn-id: trunk@34174 -
2016-07-22 13:08:32 +00:00
nickysn
a8ad82b99f + added new unit flag uf_i8086_ss_equals_ds, which indicates memory models with
SS=DS. This is currently redundant (whether SS=DS can be derived by the other
  i8086 memory model unit flags), but in the future will allow adding extra
  memory models, where the SS=DS assumption differs from the current ones.

git-svn-id: trunk@34139 -
2016-07-16 11:16:25 +00:00
Jonas Maebe
6558d7a521 * no longer store the tprocdef.synthetickind field in ppu files
git-svn-id: trunk@34130 -
2016-07-14 15:26:03 +00:00
Jonas Maebe
46166c89cb - removed no longer used and unsafe ttemprefnode.create_offset()
functionality

git-svn-id: trunk@33733 -
2016-05-21 10:28:28 +00:00
svenbarth
7d8d0340b9 Merged revision(s) 31988, 31991-31993, 32136, 32308-32309, 32312, 32318 from branches/svenbarth/packages:
Correctly parse the directives DenyPackageUnit and WeakPackageUnit

ppu.pas:
  + add flags uf_packagedeny and uf_packageweak
scandir.pas:
  + new procedure do_moduleflagswitch() which parses a ON/OFF/+/- argument and sets or clears a flag in the current module
  + new procedure dir_denypackageunit which handles DenyPackageUnit
  * implement dir_weakpackageunit (and move to the correct location ;) )
  * InitScannerDirectives: add dir_denypackageunit handler
........
Respect DenyPackageUnit flag.

pmodules.pas, proc_package:
  * check all contained units that are not already part of a package for their uf_package_deny flag and report an error for each that has it set
........
Do not check whether all units are used as by definition all units of a package are considered as used.

pmodules.pas, proc_package:
  - remove call to current_module.allunitsused
........
Check whether a unit has been implicitely imported in a package. A unit is considered as implicitely imported if it is not part of a required package nor part of the units listed in the contains section. This note is useful (Delphi even provides a dialog in that case) as a package with implicitely imported units /might/ become incompatible with other packages (e.g. if another package includes that unit uses that package and includes that unit explicitely; of course that is the same as if both package included it explicitely, but with the hint one knows where to look).

pmodules.pas, proc_package:
  * while walking the loaded units also check whether any of them not contained in a package was part of the contained units which are the same as the current module's used units
........
Generate CRC for package files

pcp.pas, tpcpfile:
  + new field do_crc which controls CRC generation
  + override putdata() method to generate CRC when data is written
  * resetfile: enable do_crc by default
........fppu.pas, tppumodule:
  * loadfrompackage: mention if a unit is loaded from a package
........
fpkg.pas, tcontainedunit:
  + new fields offset and size for the PPU data stored inside the PCP
fpcp.pas, tpcppackage:
  * readcontainedunits & addunit: correctly initialize offset and size to 0
........
Store the modified PPU files directly inside the PCP and thus get finally rid of the .ppl.ppu files.

entfile.pas:
  + new entry type ibpputable
pkgutil.pas:
  * adjust RewritePPU to work on a stream as output instead of a filename
fpcp.pas, tpcppackage:
  + new method writepputable() which writes the offsets and sizes of all contained units (not part of CRC!)
  + new method writeppudata() which rewrites all contained PPUs directly into the PCP after the ibend entry (Note: the data is written 16 Byte aligned to ease viewing of the PCP and its contained PPUs in a hex editor)
  + new method readpputable() which reads the offsets and sizes of all contained units
  + new method getmodulestream() which returns a substream for a contained module
  * loadpcp: also call readpputable()
  * writepcp: first write an empty pputable, then finish writing all data that requires the put*/write* methods of the pcpfile, then use writeppudata() to write all PPUs and finally write the correct pputable at the original location
fppu.pas, tppumodule:
  * loadfrompackage: don't read the PPU from a file if it is contained in a package, but using the new tpcppackage.getmodulestream() and tppumodule.openppustream() methods
pmodules.pas, proc_package:
  * don't rewrite the PPUs here
pcp.pas:
  * increase CurrentPCPVersion
........
Fix cycling

........

git-svn-id: trunk@33514 -
2016-04-15 13:39:41 +00:00
svenbarth
9fd8c8718a Partial merge of r28846 (without the global assembler symbols)
To correctly generate the import library for a package we need to resolve the dangling external symbols of all units. For this each unit now stores which symbols it exported from another unit and it also stores all global and external assembler symbols it has (maybe this can be streamlined later on, but for now this works).

entfile.pas:
  + new entry for the imported unit symbols
fmodule.pas, tmodule:
  + new field unitimportsyms which holds all symbols imported by a unit from another unit
  + new method to add an imported symbol
  * create, destroy & reset: correctly instantiate/free the two new lists
fppu.pas, tppumodule:
  + new field unitimportsymsderefs to hold the derefs during loading from/storing to PPU
  + new method buildderefunitimportsyms to generate the derefs for each imported symbol
  + new method derefunitimportsyms to resolve each imported symbol deref
  + new method readunitimportsyms to read the imported symbols from the PPU
  + new method writeunitimportsyms to write all imported symbols to the PPU
  * load_implementation: read the imported symbols if their entry is encountered
  * writeppu: generate the derefs for the imported symbols and write them to the PPU
  * load_usedunits: resolve the imported symbols once all derefs are known
symtable.pas:
  * addsymref: if the symbol is not from the current unit than mark it as imported
ppu.pas:
  * increase PPU version
-- Diese und die folgenden Zeilen werden ignoriert --

M    entfile.pas
M    fmodule.pas
M    fppu.pas
M    ppu.pas
M    symtable.pas

git-svn-id: trunk@33492 -
2016-04-12 20:59:35 +00:00
svenbarth
9d5f98eaa3 Merged revision(s) 28690 from branches/svenbarth/packages:
Extract reading of the PPU/PCP version into tentryfile.

entfile.pas:
  + add new getversion method which uses the pointer returned by getheaderaddr to read the PPU/PCP version
ppu.pas:
  - remove GetPPUVersion method
fppu.pas, pmodules.pas, utils/ppufiles.pp, utils/ppumove.pp, utils/ppuutils/ppudump.pp
  * replace call to GetPPUVersion by call to getversion
........

git-svn-id: trunk@32980 -
2016-01-22 15:47:29 +00:00
svenbarth
02e56f410d Merged revision(s) 28689 from branches/svenbarth/packages:
Extract functionality that is shared between the metadata files for units (PPU) and for packages (PCP) into a parent class called tentryfile

+ add new unit entfile which contains the new tentryfile class and related types and constants
* ppu.pas:
    - remove methods, fields, types and constants which were moved to entfile.pas
    * replace the parts of tppuheader shared with tentryheader by a field of type tentryheader
fppu.pas, pmodules.pas, utils/ppumove.pp, utils/ppuutils/ppudump.pp:
    + add entfile to uses
    * adjust access to common header fields
node.pas, symdef.pas, symsym.pas, symtable.pas, wpoinfo.pas, utils/ppufiles.pp:
    + add entfile to uses
........

git-svn-id: trunk@32976 -
2016-01-22 15:26:30 +00:00
Jonas Maebe
9258b5d76b + non-functional 128 bit integer types (inaccessible from Pascal), for use
in the LLVM high level code generator to implement overflow checking

git-svn-id: trunk@32735 -
2015-12-26 20:00:33 +00:00
Jonas Maebe
01d93b61c3 * save/restore the type (and hence code page) of ansistring constsyms in/from
the ppu (mantis #28964)
  * also save/restore the type of constnil, constresourcestring and constguid
    in/from the ppu

git-svn-id: trunk@32617 -
2015-12-08 14:27:23 +00:00
Jonas Maebe
f4a62c4c60 * fixed (harmless) range errors in getasizeint() after r32444
git-svn-id: trunk@32474 -
2015-11-22 11:49:47 +00:00
nickysn
62dadad93e * reimplemented tppufile.getasizeint to use sizeof(asizeint), just like tppufile.putasizeint does
git-svn-id: trunk@32444 -
2015-11-21 18:59:50 +00:00
Jonas Maebe
2d2b8c635d * detect whether or not a def/sym is registered based on its defid, so we
don't need a separate field for this
   o changed the order in which symid and realname are stored to/loaded from
     the ppufile (because tsym.create now initialised tsym.symid, and it's
     called from ppuload) -> increased ppu version

git-svn-id: trunk@32031 -
2015-10-12 21:03:09 +00:00
svenbarth
e44a51f10d symdef.pas, tprocdef:
+ new token buffer that holds the declaration of the generic function/method while the one from tdef contains the body
ppu.pas:
  * increase PPU version
utils/ppuutils/ppudump.pp:
  * also read the declaration token buffer, it's however not printed yet (ToDo!)

git-svn-id: trunk@31759 -
2015-09-18 13:46:50 +00:00
Jonas Maebe
ab0d445999 * fixed truncation errors for a*int/word in ppudump for architectures
> 32 bits

git-svn-id: trunk@31046 -
2015-06-13 22:47:56 +00:00
Jonas Maebe
0f99ae82af * increased ppu version after r30907
git-svn-id: trunk@30910 -
2015-05-25 13:04:36 +00:00
Jonas Maebe
1b43930749 - removed long deprecated/buggy assembler cse optimiser for i386
o bumped ppu version because optimiser settings can be embedded in generic
     token streams

git-svn-id: trunk@30835 -
2015-05-09 17:25:07 +00:00
florian
e0b27e1688 * unified typing and ppu reading/writing of setdef fields regarding aint/asizeint
git-svn-id: trunk@30542 -
2015-04-11 11:36:01 +00:00
Jonas Maebe
25e6eaf07f * store the to be used recordalignmin and maxcrecordalign settings inside
(abstract)recordsymtables, so that these settings don't depend on the
    current user settings when internally creating record definitions

git-svn-id: branches/hlcgllvm@30343 -
2015-03-27 21:25:56 +00:00
Jonas Maebe
5bb89cc2f0 * keep track of the reason why a loadparentfpnode has been created: to
load a value from a nested context, or to pass a context to a nested
    routine. In case a target uses both the stack and frame pointer, this
    difference can matter.

git-svn-id: trunk@29937 -
2015-02-23 22:53:59 +00:00
Jonas Maebe
b5643f2a27 + aarch64 cpu identifier
git-svn-id: trunk@29876 -
2015-02-23 22:50:38 +00:00
Károly Balogh
77088cf723 * bumped PPU version because r28596 breaks compatibility on Amiga/68k and MorphOS
git-svn-id: trunk@28597 -
2014-09-05 02:39:35 +00:00
nickysn
36d63b953e + added an i8086 specific boolean property is_huge to the tarraydef. For now it
will only be used for indexing huge pointers (i.e. only huge arrays with the
  ado_IsConvertedPointer array option will be supported). In the distant future,
  regular huge arrays may be supported as well (but that would require
  substantially more work, including adding hugeness support to other structures
  such as records, objects and classes, so I'm not planning on doing it anytime
  soon).

git-svn-id: trunk@28270 -
2014-07-26 13:27:46 +00:00
svenbarth
639a59df92 Added support for partial specialization. This should fix a few problems with generics, the tests for which will be added in the next days after I've verified them.
For partial specialization only the declaration is reparsed, but not method bodies.

The way generic parameters are passed around inside the compiler is changed: instead of creating new type symbols we keep a (name,def) pair so that the code in insert_generic_parameter_types can decide whether it needs to add a type symbol (for new undefined defs) or not (for real types and undefined defs that were passed on from the parent generic). This required the tfpobjectlist type of the genericlist variables/parameters to be changed to tfphashobjectlist.

For correctly parsing Delphi specializations as parameters in functions of records (or objects) the relationship between the def and its typesym must already be established during the parsing. For this the checks for forcing a "type is not completely defined" message needed to be adjusted to correctly handle nested types as well. This should as a sideeffect also allow the usage of nested constants, etc like was fixed for classes some months ago.

ToDo: 
  - if a generic is specialized with only fully defined types then we could generate the in the unit where it's used. This is not yet done.
  - currently we don't specialize generics that are currently parsed; maybe this could be improved in the future for better type compatibility checks
  - check whether the pausing of token recording for partial specializations works correct in context of hint modifiers

pgenutil.pas:
  * parse_generic_parameters: return a tfphashobjectlist instead of a tfpobjectlist (requires a few type adjustments in various other declarations)
  * maybe_insert_generic_rename_symbol, insert_generic_parameter_types: change genericlist from tfpobjectlist to tfphashobjectlist
  * parse_generic_specialization_types_internal: use is_generic instead of checking for df_generic
  * generate_specialization:
      + add a nested function to disable the requirement to check for method bodies
      * use the "simple" parameter parsing only for error recovery
      * instead of already creating a new type symbol for a parameter we use the found symbol's name and its def and maybe create it later on (therefor the type of tfpobjectlist was changed to tfphashobjectlist)
      * a partial specialization is specialized into the symtable of the def it is specialized in instead of one of the two global symtables
      * for now we handle partial specializations of generics we are currently parsing like before
      * don't continue recording generic tokens while we do a partial specialization
      * use the new unset_forwarddef function on the newly created defs
  * insert_generic_parameter_types: only create a new type symbol if the found type symbol does not yet have an owner (thus was freshly created for this generic declaration)

pdecobj.pas, object_dec:
  * change type of genericlist from tfpobjectlist to tfphashobjectlist
  * set the type sym for all object types that can be generic or inside a generic (needed for correctly parsing Delphi style generic declarations)

pdecsub.pas, parse_proc_head:
  * consume_generic_interface: always generate the specialization name as now all generics are "specialized" inside a generic
  * the assumption that the def index numbers are the same is no longer true as the genericdef might contain the defs of partial specializations which are not generated for full specializations

pdecvar.pas, read_record_fields:
  * we also need to check nested types whether they contain a not yet completely parsed record or object

ptype.pas:
  * read_named_type: 
      * change genericlist from tfpobjectlist to tfphashobjectlist
      * pass the typesymbol along to record_dec
  * resolve_forward_types: use is_generic instead of checking for df_generic
  * single_type: 
      * use is_generic instead of checking for df_generic
      * no need to check generic parameters
  * parse_record_members:
      + add parameter for the record's type symbol
      * setup the typesym <=> def relationship
  + record_dec: add parameter for the type symbol and pass it to parse_record_members
  * read_named_type, expr_type: use is_generic instead of checking for df_generic
  * array_dec & procvar_dec: change genericlist from tfpobjectlist to tfphashobjectlist

symdef.pas, tstoreddef:
  * improve the checks used in is_generic and is_specialization to really only work on true generics and true (and partial) specializations respectively
  * don't search the type parameters in the symtable, but store them in the PPU and load them from there
  - remove fillgenericparas method (including the calls in the descendants tarraydef, tprocvardef, tobjectdef and trecorddef)

defcmp.pas, compare_defs_ext:
  * handle partial specializations: specializations with only undefineddefs are compatible to generic defs

pdecl.pas, types_dec:
  * switch generictypelist from tfpobjectlist to tfphashobjectlist

ppu.pas:
  * increase PPU version

+ added tests that ensure that "not completely defined" checks for records (and objects) still work correctly

git-svn-id: trunk@27861 -
2014-06-05 20:05:05 +00:00
nickysn
e21783a281 * i8086 small and tiny memory model ppus made incompatible. Rationale:
o the maintenance effort will be less - previously we had to test 4
    combinations:
      tiny program with tiny rtl
      tiny program with small rtl
      small program with tiny rtl
      small program with small rtl
    I only tested both tiny and small programs with the small rtl, so I missed
    a bug, which caused small programs built with the tiny rtl to always give
    a "Nil pointer assignment" error. Now we only need to test two cases:
      tiny program with tiny rtl
      small program with small rtl
  o I'm planning a bug fix for interrupt procedures in the tiny model, which
    will make their prolog differ between small and tiny. Currently, they're
    not used in the rtl, but that may change. And even if it doesn't,
    interrupt procedures may also be used by user units.

git-svn-id: trunk@27516 -
2014-04-10 16:31:06 +00:00
svenbarth
5c1b8fdad9 Fix for Mantis #19697. For this we need to have the internal static var symbol know that it came from a static field var symbol so that we can check that for generic or not.
symsym.pas, tfieldvarsym:
  + add new field fieldvarsym which holds a reference to a tfieldvarsym if the static sym was created based on such a symbol
  + add necessary methods and code to correctly load from and store to PPU
  + add new constructor create_from_fieldvar
symcreat.pas, make_field_static: 
  * use new create_from_fieldvar constructor instead of the default one
hlcgobj.pas, finalize_static_data:
  * check whether the static var is based on a generic's class var
ppu.pas:
  * increase PPU version

+ added test

git-svn-id: trunk@27466 -
2014-04-04 16:15:41 +00:00
Jonas Maebe
f017e16722 * increased ppu version after all symdef changes
git-svn-id: trunk@27442 -
2014-04-01 21:41:40 +00:00
Jonas Maebe
1ac4021178 * moved po_has_inlininginfo from procoptions to procimploptions so that
the availability of the body of a function declared as "inline" no
    longer changes the CRC and hence no longer triggers recompilations
    (mantis #24121)

git-svn-id: trunk@27192 -
2014-03-19 21:53:10 +00:00
Jonas Maebe
7d8e9cf0f6 * moved tprocdef.isempty to a new set called implprocoptions that
contains flags related to the procdef's implementation (and that
    don't influence the interface crc)

git-svn-id: trunk@27189 -
2014-03-19 21:52:59 +00:00
svenbarth
ddb78fefdc Add a modeswitch for type helpers as discussed in core on 24th October 2013. It is disabled by default in all modes (afterall type helper support in Delphi started only beginning with XE3)
+ globtype.pas: add new modeswitch to modeswitch enum and name array
* ptype.pas & pdecobj.pas: check for new modeswitch instead of modeswitch class
* ppu.pas: increase ppu version as we've added a new modeswitch which requires correctly compiled units

* adjusted tests to enabled the modeswitch when necessary
+ added three new tests that check for correct functionality of modeswitch typehelpers

git-svn-id: trunk@26796 -
2014-02-16 12:58:24 +00:00
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
nickysn
f165cee058 + save the absolute variable's segment to the ppu file after r25666
* incremented the ppu version

git-svn-id: trunk@25672 -
2013-10-06 00:32:10 +00:00
nickysn
3b895ec0e8 * updated tppufile.getaword to support 16-bit and 8-bit aword sizes
git-svn-id: trunk@25671 -
2013-10-06 00:20:42 +00:00
nickysn
63a42b9da6 * incremented the ppu version as well after r25365
git-svn-id: trunk@25367 -
2013-08-25 16:52:37 +00:00
nickysn
243e3bbb77 + added i8086 memory model flags to the ppu flags and added a check that prevents the using of units compiled for different memory models
git-svn-id: trunk@25365 -
2013-08-25 16:45:04 +00:00
Jonas Maebe
fb8fb29574 * record/use the code page of string constants typecasted to an ansistring
type with a non-default code page
   TODO: ensure that string constants typecasted to ansistring become
     ansistrings rather than typeless string constants

git-svn-id: trunk@25207 -
2013-08-02 13:23:32 +00:00
nickysn
381c996e53 + added po_far to tprocoptions
git-svn-id: trunk@24815 -
2013-06-08 16:34:30 +00:00
svenbarth
6eaefeed7f Addendum to 24628: forgot to increase PPU version
git-svn-id: trunk@24639 -
2013-05-30 12:21:03 +00:00
nickysn
80e76534a5 * incremented CurrentPPUVersion after r24491, because it changes the ppu structure on at least one platform (ppcjvm)
git-svn-id: trunk@24496 -
2013-05-14 14:42:01 +00:00
nickysn
0d58fd6cd0 * fixed tppufile.getaint for 8/16-bit CPUs
git-svn-id: trunk@24484 -
2013-05-11 22:04:56 +00:00
florian
bac18a0094 * properly read asizeints from ppus on 16 bit targets
git-svn-id: branches/i8086@23939 -
2013-03-19 21:33:46 +00:00
nickysn
0683409703 + added i8086 to the CpuAddrBitSize and CpuAluBitSize const arrays in the 'ppu' unit
git-svn-id: branches/i8086@23839 -
2013-03-15 00:10:05 +00:00
Jonas Maebe
2b78bb1674 - removed ppc-specific tcgpara.composite field, it's no longer used or
necessary

git-svn-id: trunk@23581 -
2013-02-06 15:37:50 +00:00
florian
4d6471fef6 * get rid of calls to empty procedures having parameters without side effect
git-svn-id: trunk@23274 -
2013-01-01 15:58:05 +00:00
svenbarth
9ef4a35a7b Fix the fix for Mantis #21538. The check never really worked up to now...
defcmp.pas, compare_defs_ext:
  use "equal_defs" instead of a reference comparison to check whether the type defs are equal
pgenutil.pas, insert_generic_parameter_types:
  * add to each (specialized) generic parameter the "sp_generic_para" flag so that it will be added to the "genericparas" list upon ppu loading
  * add the generic parameter to the genericparas list as well, so that the comparison in "compare_defs_ext" is triggered at all... (up to now the list was always empty -.-)
ppu.pas:
  * increase PPU version

git-svn-id: trunk@23149 -
2012-12-15 21:43:52 +00:00
Jonas Maebe
d9e67fc835 * don't add a separate high parameter for array-of-const parameters on the
JVM target (just like for open array parameters), since the array length
    is already encoded in the array itself there

git-svn-id: trunk@22968 -
2012-11-10 20:26:42 +00:00
Jonas Maebe
c4a55f5481 * store the "synthetic kind" information about procdefs in ppu files,
required by future patch

git-svn-id: trunk@22956 -
2012-11-08 20:17:53 +00:00
Jonas Maebe
ad054831bb * save/restore itype and implementsgetter fields of timplementedinterface
to/from ppu, because it can be required while resolving type casts
    (mantis #22741)

git-svn-id: trunk@22266 -
2012-08-29 16:07:55 +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
d2fabd2a22 Fix for Mantis #21350
+ pgenutil.pas: 
    add a procedure which adds a type symbol to a non-Delphi-mode generic class or record which has the same name as the unit global dummy symbol for that generic. I don't know why I had that idea earlier as this will simplify some of the conditions in the parser again (I haven't changed these yet, but I hope to do that at least when I start working on generic functions).
* pgenutil.pas, generate_specialization:
    correctly handle "specialize TSomeGeneric<T>" as method parameter in a generic with the newly added rename symbol
* pdecobj.pas, object_dec & ptype.pas, record_dec: 
    call the procedure to add the rename symbol (the procedure checks whether the mode is correct)
* ppu.pas: 
    increase PPU version so that we don't use non-Delphi mode units with generics, but without the rename symbol
+ added tests:
    the one in webtbs are for classes/objects and those in test are for records

git-svn-id: trunk@21603 -
2012-06-14 07:07:28 +00:00
pierre
600dd162af Merge of rev21557 by Foxsen
Make macro MIPS/CPUMIPS/MIPS32 common for big endian and little endian mips processors
use MIPSEL* for little endian systems
use MIPSEB* for big endian systems

git-svn-id: trunk@21599 -
2012-06-13 22:25:38 +00:00
pierre
a805259761 + Increase CurrentPPUVersion following removal of packed attribute for tsettings type
git-svn-id: trunk@21595 -
2012-06-13 21:53:37 +00:00
florian
31b1678757 * write parameter refs to ppu (only 1=used; 0=unsed), fixes parameter usage checking of inlined procedures loaded from units
git-svn-id: trunk@21482 -
2012-06-03 18:56:44 +00:00
Jonas Maebe
4e0df2d3a4 * increased ppu version after jvmbackend merge
git-svn-id: trunk@21070 -
2012-04-26 22:48:43 +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
Jonas Maebe
93210cc419 * store JVM namespace separately from unitname so it doesn't conflict with
dotted unit names

git-svn-id: branches/jvmbackend@20872 -
2012-04-14 17:38:12 +00:00
svenbarth
bd19a16be9 Add support for Default() intrinsic. For now this is only (fully) supported
in code and not in constants. In the case of primitive types constant nodes
are used while complex types like arrays, records and objects use a local
variable which is initialized to zero once at the entry of the method (the
variable is reused if Default() is used for the same type multiple times in
the same method). For this a new compilerproc was added which uses FillChar
to initialize the given memory area to zero.
This fixes Mantis #9420.

+ psystem.pas: Added Default symbol to system unit
+ htypechk.pas: Added function "is_valid_for_default" which checks recursively
                whether the given type can be used with Default at all. 
                Forbidden types are files, helpers, ObjC and C++ types. This
                check is used for records, arrays and objects only if the mode
                is a non-Delphi one, as Delphi ignores these types on lower
                levels.
+ msg/errore.msg: Added error message for unsupported types for Default()
+ symconst.pas: Added a new enum value vo_is_default_var which is used for the
                local variables utilized by Default() so their initalization
                and finalization can be avoided.
+ pexpr.pas: Add handling of Default() intrinsic to "statement_syssym"
+ ninl.pas: Extended tinlinenode by a method which returns the correct node for
            a Default() and used that method in handle_typecheck.
* ncgutil.pas: Check for new flag "vo_is_default_var" when initializing and
               finalizing local variables.
* ppu.pas: increase PPU version
+ psub.pas: 
  * Added a new routine which zeros defaultvars of a symtable.
  * Use this routine inside "initializevars".
  * Also use this routine to initialize the staticsymtable of the unit/program.
* Adjusted ppudump, because of the new enum value.
+ Added implementation of fpc_zeromem to system unit.
+ Added tests for Default()

git-svn-id: trunk@20629 -
2012-03-25 16:02:27 +00:00
svenbarth
9cb16c950f This fixes Mantis #20851 .
For the solution symbols will now contain a "sp_explicitrename" flag if they
were created through a type rename. This is necessary, because we can't
decide whether a type is a renamed generic para which contains by default a
reference to the default undefined def. Using individual undefined defs will
lead to duplicate identifiers as they are created before a symtable was
pushed (thus they'll ba part of whatever symtable is at the top). 

+ symconst.pas, tsymoption:
        Add a new option "sp_explicitrename" which will be used to track type
        renames.
+ pdecl.pas, type_dec:
        Set the new flag if we're dealing with a type rename
* pexpr.pas, factor_read_id:
        If we have an undefined def that is also a rename then we assume that
        it's a rename of a generic parameter
* utils/ppudump.pp:
        Adjustment because of change to tsymoption
* utils/ppu.pp:
        Increase PPU version
+ added test

git-svn-id: trunk@20250 -
2012-02-04 16:03:58 +00:00
Jonas Maebe
74e721517d * keep track of the type of symbolic floating point constants rather
than always forcing them to bestreal (mantis #21151)

git-svn-id: trunk@20190 -
2012-01-28 18:38:06 +00:00
svenbarth
7986f03186 * pgenutil.pas, generate_specialization:
* When building the typename for a generic use the full typename
	  including it's surrounding object- or abstractrecorddefs. This allows
	  that a nested non-generic type of a generic type A can be used as
	  type arguments for more than one specialization of another generic B
	  (there were some problems when B e.g. defined a pointer to the type
	  argument's type)

	* Always CRC the constructed specialization name as otherwise it might
	  reach the limit of 255 characters (not yet including unit name,
	  method name or method arguments)
	  Note: Errors like "expected XYZ, but got ABC" will need to be 
		adjusted to use the prettyname...

* increased PPU version
+ added test for above's point 1

git-svn-id: trunk@20149 -
2012-01-22 13:29:12 +00:00
Jonas Maebe
e5c097a6e2 * mark nodes that have been created by transforming a read-accessor of
of a property with nf_no_lvalue flag, and check that such nodes are
    never used in direct assignments (fixes mantis #21087 and a couple of
    other cases of invalid assignments to properties)

git-svn-id: trunk@20140 -
2012-01-21 19:09:30 +00:00
svenbarth
4419dc3d34 Rebase to revision 19673
pexpr.pas: Changes in postfixoperators and the base of handle_factor_typenode not yet incorporated (the code from trunk was simply commented for now)

git-svn-id: branches/svenbarth/generics@19676 -
2011-11-24 16:48:47 +00:00
svenbarth
461d231daa Rebase to revision 19078 (directly before the merge of cpstrnew)
The changes regarding pretty names for generics and token buffer endianess were integrated into my changes. Not every call to generate_specialization is fixed though, so compilation will fail.

git-svn-id: branches/svenbarth/generics@19674 -
2011-11-24 10:19:57 +00:00
svenbarth
594f84dc2c Merge branch 'unique-syms'
Conflicts:
	compiler/pdecl.pas
	compiler/pexpr.pas
	compiler/pgenutil.pas
	compiler/ptype.pas

The original log messages as git was a bit forgetting here :( (newest at the top):

commit 7ef252de8023494ee6d39910e289f9e31658d47b
Author: Sven Barth <pascaldragon@minerva>
Date:   Mon Nov 21 17:13:36 2011 +0100

    Fix the compilation of inline specializations of which the generic is derived from another generic.
    
    pgenutil.pas, generate_specialization:
    * Set the "block_type" to "bt_type" when parsing the type parameters, so that the nodes are returned as "ttypenode" instead of e.g. "tloadvmtaddrnode" in case of classes outside of type sections.
    * Set the "block_type" to "bt_type" before calling "read_name_type", so that no unexpected sideeffects happen, because types like classes normally only are declared inside type sections (e.g. for the case a generic class is derived from another generic class a classrefdef for the specialized parent class will be created inside the derived specialized class if the block type is not a type one).

commit 1041a8f7a3a41f4fdf2975ce40055c698281ce71
Author: Sven Barth <pascaldragon@minerva>
Date:   Fri Nov 18 19:03:50 2011 +0100

    Improve inline specializations a bit, so now expressions like "TSomeGeneric<TSomeType>.SomeClassProc OP SomeNonGeneric" is possible. Using another class function of a generic as the right side is not yet working (that still needs some thinking).
    
    To achive this the generalization code must basically continue directly after the "factor" call, so that the operator and the right side are correctly parsed when walking up the call stack. This is done by jumping from the end of the specialization code in the "<"-case to the start of "sub_expr". The freshly generated node (in the above example a callnode) will be passed down the callstack through a new parameter "factornode". If that is set (currently only in the case of a specialization on the left side) "factor" won't be called and the right side will be parsed with the "factornode" as the left side. If it is not set (which is the case for all other calls to "sub_expr" in the unit) then the usual call to "factor" will be done and the result will be used as the left side.

commit a01ccd265f8d6cc5a2f3e88e23afbcd3d5960afb
Author: Sven Barth <pascaldragon@minerva>
Date:   Fri Nov 18 18:37:04 2011 +0100

    Fix compilation of ppudump.
    
    symconst.pas:
    * Remove sto_has_generic, which was the last remainer of my "overloaded type symbols" approach.
    * Remove df_methods_specialized, as it isn't needed anymore with the recent "temporary symtable" solution.
    
    psub.pas, specialize_objectdefs, process_abstractrecorddef:
    Remove the checks for/inclusion of df_methods_specialized.
    
    utils/ppudump.pp:
    Add "sp_generic_dummy" to the symbol options.

commit d16deac060e65d4b53e8fe9c27fe7e1f6d00a416
Author: Sven Barth <pascaldragon@minerva>
Date:   Wed Nov 16 16:34:51 2011 +0100

    Fix compilation of "gset.pp" from fcl-stl.
    
    nld.pas:
    Extend ttypenode by a reference to the type symbol. Normally this is simply the typesym of the given def, but for specializations in type sections of generics this is not the case, because generate_specialization will return a reference to the generic definition and not the new one (thus the symbol will be wrong).
    
    ppu.pas:
    Increase PPU version because of the extension of ttypenode.
    
    pexpr.pas:
    * handle_factor_typenode: Extend the function by a "sym" parameter which will normally be "nil". In that case it is set to the def's typesym. The "typesym" field of the created type node is then set to this sym.
    * For now pass nearly always "nil" for the above mentioned sym except inside factor_read_id when we've encountered a typesym.
    
    ptype.pas, read_named_type, expr_type:
    Exchange the "is_owned_by" check with a "sym_is_owned_by" check so that we can correctly detect that we are using a specialized type declaration inside a generic (once nested generic are allowed this condition needs to be checked).

commit 23668d2fc9070afc26b4288ed0db9a8eaf6f40e6
Author: Sven Barth <pascaldragon@minerva>
Date:   Wed Nov 16 07:51:12 2011 +0100

    psub.pas:
    * tcgprocinfo.parse_body: Methods of generic classes need to set "parse_generic" as well, so that variables for "stacked generics" (generic array => generic record) inside the method body are handled correctly.
    * specialize_objectdefs: Don't try to generate method bodies for abstract methods.
    
    pdecvar.pas, read_property_dec:
    Allow specializations for the return types of properties (should they be allowed for index types as well?).
    
    symtable.pas:
    Add a new class "tspecializesymtable" which is basically a globalsymtable but is always assuming to be the current unit. This symtable is used in "generate_specializations" (see below) and is needed to allow visibilty checks for "private", etc. to succeed.
    
    pgenutil.pas, generate_specializations:
    Instead of hackily pushing a symtable that may contain conflicting symbols onto the symtable stack for the specialization, a temporary global symtable using the above mentioned "tspecializesymtable" is created and pushed. After the specialization is done all symbols and defs that were added to the temporary symtable are moved to their final symtable (either the global- or localsymtable of the unit, depending on the current position of compilation). This way symbols are correctly added to a top level symtable, but without potential side effects like resolving the wrong symbol.

git-svn-id: branches/svenbarth/generics@19671 -
2011-11-23 17:25:09 +00:00
paul
a1e0b833b2 compiler: fix ppu read/write of property parameters symtable (bug #0020454)
- add new property option ppo_overrides for property which overrides parent class properties
  - write overriddenpropsymderef only in case if property has ppo_overrides flag
  - save/load parameters symtable only in case if property has ppo_parameters flag and has not ppo_overrides flag
  - in case if property is overrides and has parameters copy original symtable

git-svn-id: trunk@19615 -
2011-11-09 03:35:55 +00:00
pierre
019ecd53fe Use out parameter type for tppufile.getXXX methods
git-svn-id: trunk@19586 -
2011-11-03 11:09:34 +00:00
paul
62b4ef3d1a compiler: don't create a parasymtable for property if property has no parameters
git-svn-id: trunk@19550 -
2011-10-28 01:38:55 +00:00
paul
ceb141523d compiler: store property parameters in a parasymtables together with property. restore those parameters for descendant properties (fixes mantis #0020421 but maybe not very optimal)
git-svn-id: trunk@19400 -
2011-10-07 05:58:58 +00:00
paul
7a74d2c2f8 compiler: reduce amount of hints and notes
git-svn-id: trunk@19293 -
2011-09-30 08:56:05 +00:00
pierre
a17390126a Fix an error in reading real variable for change_endian
git-svn-id: trunk@19023 -
2011-09-07 23:19:48 +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
sergei
689d4b3ecc + Mantis #19651: Generate table of typed string constants which are initialized with resourcestrings, so they are updated when SetResourceStrings or SetUnitResourceStrings is called.
git-svn-id: trunk@18968 -
2011-09-04 16:01:26 +00:00
pierre
4c633c46ed Change mangling to avoid overlap and increase PPU version
git-svn-id: trunk@18946 -
2011-09-02 14:20:14 +00:00
paul
de21de2024 compiler: implement delphi like namespaces
git-svn-id: branches/paul/namespaces@18859 -
2011-08-27 03:52:07 +00:00
Jonas Maebe
6154f1b0d9 * keep track of the number of abstract methods per class via a counter
* use this counter to mark classes containing abstract methods as
    "abstract" in the bytecode per the JVM spec
  * also use the counter to short-circuit printing of all abstract
    methods in a class when creating a new instance (we build the list
    of abstract methods every time a new instance is created, which is
    a waste of time if there are none in the first place)

git-svn-id: branches/jvmbackend@18635 -
2011-08-20 08:17:12 +00:00
Jonas Maebe
6bc68a11d9 * determine size of aword/aint/asizeint based on type size instead of based
on defines

git-svn-id: branches/jvmbackend@18602 -
2011-08-20 08:14:14 +00:00
Jonas Maebe
c943d703fd * fixed range check error when compiling with -dTest_Double_checksum
(although it crashes later for other reasons)

git-svn-id: branches/jvmbackend@18601 -
2011-08-20 08:14:09 +00:00
Jonas Maebe
ce88df680b + symansistr conditional define that, when activated, makes the symbol/
mangled name handling ansistring rather than pshortstring based (required
    for JVM target; little effect on speed, some extra memory usage)

git-svn-id: branches/jvmbackend@18597 -
2011-08-20 08:13:50 +00:00
Jonas Maebe
1e2c70796e + jvm (cpu architecure) and java ("OS"/target) identifiers
+ basic target information for jvm target (assembling/linking
    helpers are still dummies for now)
  + basic jasmin assembler writer
  + cpunode and cputarg units to include the target units in the
    compiler

git-svn-id: branches/jvmbackend@18309 -
2011-08-20 07:37:33 +00:00
florian
275c6092e5 * avoid range check errors for empty ansistrings written/read from ppus
git-svn-id: trunk@18253 -
2011-08-17 19:01:03 +00:00
florian
79a96ab287 + ttypesym.prettyname
* write names of specialization type syms more pretty

git-svn-id: trunk@18241 -
2011-08-17 11:10:00 +00:00
sergei
fec5dde5b6 * Fix handling of Windows WideString typed constants, resolves #15842 and completes the related #14308:
* Do not initialize unused symbols, because finalization code is not generated for them either.
  * Always initialize/finalize such constants, even if they are declared in {$J-} state and cannot be modified by user code.

git-svn-id: trunk@18121 -
2011-08-06 18:11:39 +00:00
Jonas Maebe
0398ff6bf5 * also save/restore the size of the padding of record/objectsymtables
* when creating a child class, ignore the padding added to the parent
    in case of objcclasses (gcc/clang also do that; maybe the same
    has to be done for cppclass as well)
  -> objcclass layouts seem to finally completely match the gcc ones

git-svn-id: trunk@18119 -
2011-08-06 18:01:39 +00:00
Jonas Maebe
1c11f6c8b7 + tppufile.putasizeint()
* save/restore tabstractrecordsymtable.datasize as asizeint instead of
    aint (not ppu version change because they are the same on all
    production targets)
  * add shortint() typecasts when reading/writing fieldalignment/
    recordalignment fields

git-svn-id: trunk@18118 -
2011-08-06 17:18:21 +00:00
Jonas Maebe
86b088f398 * store the current field alignment of tobjectdefs that use C_alignment,
because it influences the offset at which the next field in child classes
    should be placed in case it also uses C_alignment
  * also pad objectdefs based on the packrecords setting (Delphi-compatible)
  -> field offset calculation in objcclasses is now correct if they are
     compiled with {$packrecords c}

git-svn-id: trunk@18114 -
2011-08-06 13:11:23 +00:00
pierre
322e3f8a16 * More fixes for ppudump use
git-svn-id: trunk@17956 -
2011-07-08 15:38:14 +00:00
pierre
dd96bfb3dd * fix ppu dumping with ppudump utility for cross CPU
git-svn-id: trunk@17952 -
2011-07-08 08:57:24 +00:00
pierre
239944f8d0 + Use DLL name in assembler labels used to import DLL functions/variables
in Windows, Emx and OS2 targets.
    This fixes test failures: test/library/tlib1b.pp and lib2b.pp

    link unit TLinker.AddImportSymbol: Added symmangledname parameter.
    ogbase unit TImportSymbol.Create: Add AMangledName parameter.
    fmodule unit TModule.AddExternalImport: Add symmangledname parameter.
    fppu unit: Also put mangled name string for imported symbol.
    ppu unit: Increase PPUVersion
    utils/ppudump.pp: Adapt to PPU change above.
    systems/T_OS units: Use ImportSymbol.MangledName property to create
    import libraries or .idata sections.

git-svn-id: trunk@17804 -
2011-06-23 11:38:57 +00:00
pierre
09e9d922c7 * Reset F to NIL after freeing in tempclose
git-svn-id: trunk@17683 -
2011-06-07 16:10:25 +00:00
pierre
82ffdb48c9 * Fix tppufile.tempopen method needed for go32v2 cycle
git-svn-id: trunk@17674 -
2011-06-06 16:11:19 +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
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
paul
d21bbc4548 compiler: reduce amount of hints and warnings
git-svn-id: trunk@17350 -
2011-04-20 02:58:52 +00:00
svenbarth
35b47e491c Rebase to revision 17306
git-svn-id: branches/svenbarth/classhelpers@17314 -
2011-04-13 10:04:14 +00:00
florian
c97869bd89 * merge user sections support branch
git-svn-id: trunk@17285 -
2011-04-10 18:08:59 +00:00
florian
0c62133d38 * patch by Mattias Gaertner to allow to override how the compiler reads source/ppu files, resolves #18740
git-svn-id: trunk@17255 -
2011-04-05 20:10:09 +00:00
florian
e4656050a7 + get/putansistring
git-svn-id: branches/usersections@17153 -
2011-03-20 15:39:33 +00:00
svenbarth
80e6498921 Rebase to revision 17096
git-svn-id: branches/svenbarth/classhelpers@17099 -
2011-03-09 16:29:47 +00:00
florian
26fbfaf5a7 + introduce the usage of asizeint/asizeuint for cpus with sizeof("alu")<>sizeof(pointer)
git-svn-id: trunk@17011 -
2011-02-26 20:10:03 +00:00