Commit Graph

989 Commits

Author SHA1 Message Date
Jonas Maebe
e34a16d1f1 * change rtti_mangledname resultdef into TSymStr
git-svn-id: trunk@31245 -
2015-07-30 16:57:45 +00:00
Jonas Maebe
b21610050f * don't store reusable defs based on other defs from localsymtables into the
static/globalsymtable. The static/global symtable is stored to the PPU
    while the localsymtables are not, which means we get dangling references
    when reloading such defs from the ppu afterwards

git-svn-id: trunk@31149 -
2015-06-23 21:23:25 +00:00
Jonas Maebe
508828958c * changed getprocaddressprocvar() into a tprocvardef.getreusableprocaddr()
class method

git-svn-id: trunk@31148 -
2015-06-23 21:23:22 +00:00
Jonas Maebe
f40ea04540 * changed getarraydef() into a tarraydef.getreusable() class method
git-svn-id: trunk@31147 -
2015-06-23 21:23:18 +00:00
Jonas Maebe
f402b0d7df * changed getpointerdef() into a tpointerdef.getreusable() class method
o allows removing the ugly x86 hacks

git-svn-id: trunk@31144 -
2015-06-22 08:17:49 +00:00
Jonas Maebe
3f736f6114 * handle the loading of VMT entries at the node level, so it's done in a
type-safe way (for LLVM, and also internal consistency checking between
    the VMT as generated in nobj.pas and ncgvmt.pas)
   o also converted the VMT validity checking to the node level

git-svn-id: trunk@30950 -
2015-05-31 16:50:47 +00:00
Jonas Maebe
48ffe7b033 * don't create RTTI for internally generated recorddefs (doing so can cause
undefined references to RTTI for some of the fields, and we don't need
    it anyway because these types are not user-visible and we don't generate
    variables of these types)

git-svn-id: trunk@30945 -
2015-05-31 16:50:33 +00:00
Jonas Maebe
bd8079f896 * cache and reuse procvardefs internally created to get the address of a
procdef (halves the amount of memory needed to compile the googlapi
    package using a build unit, as done by fpmake)

git-svn-id: trunk@30856 -
2015-05-14 15:36:20 +00:00
Jonas Maebe
fb8c61889b * when getting a copy of a special procdef (such as a con/destructor) as a
procvardef, change the proctype into a regular procedure/function,
    because there are no "con/destructor procvar" types and there is code
    in the paramanager that expects e.g. a constructor to be always owned by an
    abstractrecorddef (which is not necessarily the case for the created
    procvardefs)

git-svn-id: trunk@30786 -
2015-05-03 16:51:20 +00:00
nickysn
8cf469e9ef * base the default alignment on voidpointertype.alignment instead of
voidpointertype.size for all types, that are internally represented as a
  pointer (ansi/widestrings,dynarrays,classes)

git-svn-id: trunk@30683 -
2015-04-20 12:44:11 +00:00
Jonas Maebe
3be51e1455 * fixed endless recursion in tabstractrecorddef.contains_float_field() in
case a record contains an internal typed constant of its own type
    (which happened becuase such a typed constant is also fieldvarsym, solved
     by checking for sp_static) (mantis #27880)
  * fixed several other similar cases in the compiler where we are only
    interested in instance fields, but processed all fieldvarsyms

git-svn-id: trunk@30614 -
2015-04-16 21:25:22 +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
c32b6b01ad * make sure the calcparas() is called when calling getcopyas() on a
procvardef

git-svn-id: trunk@30371 -
2015-03-29 18:16:54 +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
765044aede * fixed a number of (mostly false) warnings regarding uninitialised
variables with -Oodfa

git-svn-id: branches/hlcgllvm@30244 -
2015-03-15 21:10:50 +00:00
Jonas Maebe
bd203a5b57 * synchronised with trunk till r30240
git-svn-id: branches/hlcgllvm@30241 -
2015-03-15 19:44:58 +00:00
florian
f0984fb628 * abstractrecorddef.contains_float_field should search recursively, resolves #27580
git-svn-id: trunk@30168 -
2015-03-11 22:05:14 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
florian
0a17a08b28 - remove accidently committed (commented though) debug statement
git-svn-id: trunk@30000 -
2015-02-24 20:58:49 +00:00
Jonas Maebe
79a06b1514 + iphonesim/x86_64 target (64 bit iOS simulator)
git-svn-id: trunk@29970 -
2015-02-23 22:56:09 +00:00
Jonas Maebe
0203f5e32f * search iphoneall rather than cocoaall for Cocoa types on Darwin/AArch64
git-svn-id: trunk@29922 -
2015-02-23 22:53:04 +00:00
Jonas Maebe
851b3499b4 * aarch64 only/always uses its vector fpu
git-svn-id: trunk@29917 -
2015-02-23 22:52:48 +00:00
Jonas Maebe
73a9dc8077 * fixed formatting
git-svn-id: trunk@29826 -
2015-02-23 22:48:05 +00:00
florian
bc672e8fb2 * do not mess with the global symbol when compiling the implementation part of a unit
git-svn-id: trunk@29810 -
2015-02-23 22:09:46 +00:00
florian
cab98a58d0 + parameters of nested procedure variable parameters are taken into account during name mangling, resolves #27515
* de-duplicated parameter name mangling code

git-svn-id: trunk@29791 -
2015-02-22 09:16:20 +00:00
florian
726a78be08 * fix possible range check errors, resolves #27461
git-svn-id: trunk@29743 -
2015-02-17 21:14:47 +00:00
Jonas Maebe
071282b286 * add methods of objcprotocols to the list of visible "helper" methods when
loading them from ppu (like was already done when they were initially
    compiler), so they can be called via the "id" type even if no classes are
    in scope that implement them

git-svn-id: trunk@29686 -
2015-02-13 15:43:34 +00:00
svenbarth
ba75fd62f0 Fix for Mantis #27348. Applied patch by Do-wan Kim plus comments for the reason.
symdef.pas:
  * tprocdef.defaultmangledname: add some kind of differentiator to the result def, so that x(integer;integer) and x(integer):integer generate different mangled names
  * make_mangledname: also use the returndef instead of a potentially uninitialized variable like was done for tprocdef.defaultmangledname and also add a prefix (so that the two are compatible)

+ added test

git-svn-id: trunk@29579 -
2015-01-30 13:49:25 +00:00
svenbarth
943a094683 Fix for Mantis #27320.
symdef.pas, tprocdef:
  * defaultmangledname: don't use the potentially unassigned hp, but use - as intended - returndef if it is set (analog to the non-CRC part)

+ added test

git-svn-id: trunk@29537 -
2015-01-23 16:47:23 +00:00
Jonas Maebe
146e3bcb9e * synchronised with trunk till r29513
git-svn-id: branches/blocks@29516 -
2015-01-21 23:28:34 +00:00
Jonas Maebe
e97f31541e - reverted partial commit of merge
git-svn-id: branches/blocks@29515 -
2015-01-21 23:24:37 +00:00
Jonas Maebe
a76bbf363d * synchronised with trunk r29513
git-svn-id: branches/blocks@29514 -
2015-01-21 23:18:29 +00:00
sergei
d4969ca2ee * Fixed subscripting records of size OS_PAIR on big endian targets and enabled placing such records into registers. Tested and shows no regressions on mips-linux.
git-svn-id: trunk@29493 -
2015-01-17 11:30:19 +00:00
svenbarth
5848637db3 Fix generation of class names for specializations.
symdef.pas, tstoreddef:
  * is_specialization: fix exit condition to correctly recognize specializations

+ added test

git-svn-id: trunk@29328 -
2014-12-26 18:14:52 +00:00
svenbarth
77df68b2d9 Fix basically a regression since the reworking of Delphi compatible generics. The typenames of specialization now (again) contains the type names of the parameters. Additionally they are nicely formatted (TypeName<UnitName1.TypeName1[,...]>. If the full string should be longer than 255 characters an ellipsis will be added accordingly instead of the remaining parameters.
symdef.pas, tabstractrecorddef:
  + new private field rttistring to hold the string generated by RttiName
  * instead of generating the RTTI name each time on the fly it is generated only once and additionally contains (symbollically) the amount of type parameters for generics and all type parameters for specializations including their units

git-svn-id: trunk@29275 -
2014-12-12 17:25:15 +00:00
marco
2578514853 * first dragonfly patch (existing most). Mantis #27091
git-svn-id: trunk@29213 -
2014-12-07 20:27:02 +00:00
sergei
07ab3fbec4 * Fixed RTTI name mangling for nested types, resolves #26069.
git-svn-id: trunk@28958 -
2014-11-01 14:54:16 +00:00
Jonas Maebe
95b95497d4 * mark the typesyms generated in trecorddef.create_global_internal() as used
so that they don't cause hints about unused types

git-svn-id: branches/hlcgllvm@28762 -
2014-10-06 20:53:43 +00:00
Jonas Maebe
854fe2230a * store the vmt field rather than only its offset in tobjectdef, so we can
easily find it again later (since it's hidden and doesn't have a fixed
    name, it's hard otherwise). Needed for the typed constant builder.

git-svn-id: branches/hlcgllvm@28760 -
2014-10-06 20:53:38 +00:00
Jonas Maebe
489594f02f * fixed copy/paste error in r28322
git-svn-id: branches/hlcgllvm@28759 -
2014-10-06 20:53:36 +00:00
Jonas Maebe
0def3629cc * factored out adding a single field to a record based on a def
git-svn-id: branches/hlcgllvm@28757 -
2014-10-06 20:53:30 +00:00
Jonas Maebe
864b36fbe5 * create the recorddef at the start when building an anonymous recorddef,
so that we can already refer to its def while we are sill parsing
    individual elements

git-svn-id: branches/hlcgllvm@28750 -
2014-10-06 20:53:12 +00:00
Jonas Maebe
b18ba8e85b * syncrhonised with trunk up till r28471
git-svn-id: branches/hlcgllvm@28495 -
2014-08-19 20:23:11 +00:00
Jonas Maebe
63a3ff3c7f * integrate the functionality to create an address-only procvardef from a
procdef into tprocdef.getcopyas()

git-svn-id: branches/hlcgllvm@28474 -
2014-08-19 20:22:06 +00:00
Jonas Maebe
6f01bb56d6 * automatically call calcparas adter creating a procvardef from a procvdef,
so it doesn't have to be done explicitly anymore afterwards

git-svn-id: branches/hlcgllvm@28473 -
2014-08-19 20:22:03 +00:00
Jonas Maebe
83c7dbb7a6 * fixed copy/paste error that caused all warnings to be disabled after
compiling the symdef unit while building a compiler for a non-64 bit
    code generator

git-svn-id: trunk@28462 -
2014-08-18 23:03:54 +00:00
Jonas Maebe
ee76e8dbf5 * fixed warning about always-true comparison when compiling a 16 bit target
git-svn-id: trunk@28461 -
2014-08-18 23:02:12 +00:00
Jonas Maebe
5c75b6dd6b * synchronised with trunk up till r28402
git-svn-id: branches/hlcgllvm@28403 -
2014-08-13 16:04:30 +00:00
Jonas Maebe
6e1d370417 * split off the texceptaddr declaration into rtl/inc/excepth.inc, so it can
be included at the start of the implementation of the system unit (before
    the rest of except.inc)
  * catch declarations in/loading from the system unit of the TExceptAddr type
  * use this type instead of hardcoded size constants in the compiler
  * in generic code that is active for all targets, puts its use in a virtual
    method since it's only valid for targets using setjmp/longjmp-style
    exception handling (and the record is not defined at all in the JVM RTL)

git-svn-id: branches/hlcgllvm@28376 -
2014-08-10 19:40:29 +00:00
Jonas Maebe
5a49727cdf * moved functionality to create a global recorddef based on a tfplist of
tdefs to the new trecorddef.create_global_from_deflist() constructor

git-svn-id: branches/hlcgllvm@28322 -
2014-08-06 18:04:24 +00:00
nickysn
e6c5c35d65 * tarraydef.create_from_pointer changed to require the actual pointerdef as a
parameter, instead of the element def. This will allow e.g. creating huge
  arrays from huge pointers on i8086.

git-svn-id: trunk@28268 -
2014-07-26 10:39:18 +00:00
svenbarth
d46ae01589 Fix inlining of record methods across units if the unit with the method definitions is already compiled.
symdef.pas:
  + tabstractrecorddef: implement buildderefimpl and derefimpl which works on the symtable (especially derefimpl is important here)
  - trecorddef & tobjectdef: remove buildderefimpl; it's already handled by the tabstractrecorddef one now
  - tobjectdef: remove the part of derefimpl that's already handled by tabstractrecorddef

git-svn-id: trunk@28267 -
2014-07-25 22:01:23 +00:00
nickysn
86726a5dc8 * return ptrsinttype instead of sinttype in pointerdef.pointer_arithmetic_int_type
git-svn-id: trunk@28259 -
2014-07-24 15:17:15 +00:00
nickysn
33dac14554 * defutil.get_int_type_for_pointer_arithmetic replaced with a virtual method
tpointerdef.pointer_arithmetic_int_type

git-svn-id: trunk@28258 -
2014-07-24 14:18:57 +00:00
Jonas Maebe
bd09b88a5b + support for http://en.wikipedia.org/wiki/Blocks_(C_language_extension)
o blocks are implemented as a variation of procedure variables
   o declaration of a block variable: "test: procedure(c: char) is block;"
     (C equivalent: (void)(^test)(char c) )
   o the compiler automatically converts procedures/functions whose address
     is passed to a block parameter or assigned to a block variable into
     a "block". This consists of
    1) generating a block descriptor (containing the size of the "block
       literal" (see below) and the signature of the invocation function
       encoded as an Objective-C selector)
    2) generating a wrapper function around the original funcion (with C
       calling convention), that has an extra first hidden parameter
       (marked as vo_is_parentfp in the compiler) whose type is a pointer
       to the describing "block literal"
    3) generating the "block literal", which contains a pointer to an
       external variable indicating whether this block captures context or
       not, some flags (see compiler/blockutl.get_block_literal_flags for
       info), a pointer to the wrapper function and a pointer to the
       descriptor. In the future, it will also contain captured variables.
   o right now, only global procedures/functions can be converted to blocks
     (because they don't require state capturing). The next steps are (Object
     Pascal) methods (not Objective-C methods, because Objective-C method
     procvars don't exist) and finally nested functions
   o on Mac OS X, the functionality will only work on Mac OS X 10.7 and later,
     because we have to use the so-called "ABI.2010.3.16" to ensure that
     our blocks aren't called as variadic functions by the runtime (which
     came out after the Mac OS X 10.6 release)
   o while the currently implemented functionality does not require any
     library support at all, there's no use enabling it on other platforms
     because unless it has been confirmed to work with a blocks runtime,
     there's no point in using blocks (they're just somewhat bulky procvars
     right now). Enabling it on other platforms (in combination with the
     GNUStep Objective-C run time), should simply be a matter of adding
     the right {$linklib xxx} statement to rtl/inc/blockrtl.pp file, adding
     that file to Makefile.fpc for that platform and adding that platform
     to the compiler/systems.systems_blocks_supported set

git-svn-id: branches/blocks@28232 -
2014-07-18 09:15:22 +00:00
Jonas Maebe
627c83e828 * when creating a bare procdef copy, don't copy the funcret parameter.
This is useful if you want to change the calling convention of the copy.
   o call insert_funcret_para() after creating a bare copy
  * don't copy aliasnames of copied procdefs either (can at best result
    in duplicate symbol errors)

git-svn-id: trunk@28227 -
2014-07-18 09:09:11 +00:00
nickysn
9b3d41d9c7 * the default value of tpointerdef.pointer_subtraction_result_type changed to
ptrsinttype

git-svn-id: trunk@28220 -
2014-07-15 06:51:56 +00:00
nickysn
d86a8ebc99 * defutil.get_int_result_type_from_pointer_subtraction moved to a virtual
method tpointerdef.pointer_subtraction_result_type

git-svn-id: trunk@28219 -
2014-07-14 23:30:29 +00:00
nickysn
c8130843b2 * fixed 'cannot convert type' error when comparing two voidhugepointers with
= or <>

git-svn-id: trunk@28158 -
2014-07-04 23:54:47 +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
24fcac9f87 + added support for nested procvars in the i8086 far data memory models
git-svn-id: trunk@27812 -
2014-05-22 23:44:09 +00:00
nickysn
fc71081b74 * i8086 and i386-specific code from tabstractprocdef.is_pushleftright moved to
symi86

git-svn-id: trunk@27549 -
2014-04-12 15:34:08 +00:00
nickysn
0a515311e6 * tabstractprocdef.address_type i8086-specific code moved to symcpu, ifdef i8086 removed
git-svn-id: trunk@27548 -
2014-04-12 15:09:17 +00:00
nickysn
37168c8625 * use voidcodepointertype to determine tprocvardef.size; ifdef i8086 removed
git-svn-id: trunk@27546 -
2014-04-12 14:19:30 +00:00
nickysn
89584164b1 + added virtual methods tabstractprocdef.declared_far and .declared_near, which
are called, when the 'near' or 'far' directive is parsed in a procedure
  definition. This allows overriding and implementing them on architectures,
  which support near and far calls.

git-svn-id: trunk@27545 -
2014-04-12 12:55:05 +00:00
nickysn
b41892f048 * set po_far in the i8086-specific descendants of tprocdef and tprocvardef,
instead of in tabstractprocdef.create; ifdef i8086 removed

git-svn-id: trunk@27544 -
2014-04-12 12:17:10 +00:00
nickysn
902d118ec8 * i8086 far data memory model fixes in tobjectdef.vmtmethodoffset
git-svn-id: trunk@27539 -
2014-04-11 23:05:42 +00:00
nickysn
8d9fda9264 * use voidcodepointertype.size in tobjectdef.vmtmethodoffset, avoid ifdef i8086
git-svn-id: trunk@27538 -
2014-04-11 22:09:30 +00:00
nickysn
542719c8f5 + added symdef.voidcodepointertype
git-svn-id: trunk@27536 -
2014-04-11 20:47:45 +00:00
Jonas Maebe
4a0528399e * check all overloaded routines for mangled name conflicts on the JVM
platform, as different Pascal declarations are mapped to the same
    JVM representation

git-svn-id: trunk@27520 -
2014-04-10 21:07:14 +00:00
Jonas Maebe
d452686c39 * moved pbestrealtype from symdef to symcpu
git-svn-id: trunk@27441 -
2014-04-01 21:41:37 +00:00
Jonas Maebe
a251b270b6 - removed no longer used jvmdef unit from uses clause
git-svn-id: trunk@27440 -
2014-04-01 21:41:33 +00:00
Jonas Maebe
93d50bc287 * moved jvm-specific classdef-related fields from tenumdef to a platform-
specific descendant

git-svn-id: trunk@27439 -
2014-04-01 21:41:30 +00:00
Jonas Maebe
9c7c64a3af * moved amiga/morphos-specific libsym-related field from tprocdef to
cpu-specific descendants (unfortunately causes some duplication, but the
    code is trivial and there is no easy way to avoid it)
  * also moved the use of the field in ncal to cpu-specific files (with same
    caveat)

git-svn-id: trunk@27438 -
2014-04-01 21:41:27 +00:00
Jonas Maebe
5053a39501 * moved ARM-specific tprocdef.total_stackframe_size field to cpu-specific
descendant

git-svn-id: trunk@27437 -
2014-04-01 21:41:24 +00:00
Jonas Maebe
f101118cd6 * moved MIPS-specific tprocdef.total_local_size field to cpu-specific
descendant

git-svn-id: trunk@27436 -
2014-04-01 21:41:21 +00:00
Jonas Maebe
d020a32b9a - removed no longer used tprocdef.fpu_used field for i386/i8086 (the one
place where it was used, we now handle the consequence directly)

git-svn-id: trunk@27435 -
2014-04-01 21:41:18 +00:00
Jonas Maebe
806bf0b88e - removed storing/loading unused byte for tprocdef.fpu_used
git-svn-id: trunk@27434 -
2014-04-01 21:41:14 +00:00
Jonas Maebe
338c064beb * moved x86-specific tpointerdef functionality to architecture-specific
descendants

git-svn-id: trunk@27397 -
2014-03-30 21:04:36 +00:00
Jonas Maebe
43992495cb * moved jvm tprocdef name mangling to jvm-specific descendant class
git-svn-id: trunk@27395 -
2014-03-30 21:04:29 +00:00
Jonas Maebe
f4c0daddb4 * moved jvm-specific exprasm field from tprocdef to jvm-specific descendant
git-svn-id: trunk@27394 -
2014-03-30 21:04:25 +00:00
Jonas Maebe
11c7d5223c * moved ifdef'd jvm code from tprocvardef to jvm-specific descendant
git-svn-id: trunk@27386 -
2014-03-30 17:15:57 +00:00
Jonas Maebe
a05b078fa0 * made ppuload_platform() virtual (should have been part of r27378)
git-svn-id: trunk@27385 -
2014-03-30 17:15:53 +00:00
Jonas Maebe
2474369dde * made all ppuwrite methods in leaf classes "final", because you cannot
override them safely in subclasses to add more data (they finalise
    writing their ibentry)
  * removed "virtual" from all ppuload constructors for similar reason
    as above
  + added virtual (empty) ppuwrite_plaform() method that is called from
    tstoreddef/tstoredsym.ppuwrite(), which can be safely overridden in
    child classes to add extra data (called centrally from a new
    tstoreddef/sym.writeentry() method)
  + added virtual (empty) ppuload_platform() method that is called from
    tstoreddef/tstoredsym.ppuload(), which can be safely overridden in
    child classes to read the extra data (unfortunately cannot be called
    from one single location, and these calls had to be added for each
    generic subclass separately)

git-svn-id: trunk@27378 -
2014-03-30 15:42:49 +00:00
Jonas Maebe
b57c95043f + support overriding tdef/tsym methods with target-specific functionality:
o made all (non-abstract) tdef and tsym constructors virtual
   o added c*def/c*sym classref types for every (non-abstract) t*def/t*sym
     class
   o added cpusym unit for every architecture that derives a tcpu*def/tcpu*sym
     class from the base classes, and initialises the c*def/c*sym classes with
     them. This is done so that the llvm target will be able to derive from
     the tcpu*def/sym classes without umpteen ifdefs, and it also means that
     the WPO can devirtualise everything because the c* variables are only
     initialised with one class type
   o replaced all t*def/t*sym constructor calls with c*def/c*sym constructor
     calls

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
Jonas Maebe
57859963d6 - removed {$ifdef compress} code (it hasn't been activated/maintained since
a very long time)

git-svn-id: trunk@27359 -
2014-03-29 22:31:46 +00:00
nickysn
b1f69349f8 * use voidpointertype.size to obtain the current data (self) pointer size,
instead of checking the i8086 memory model manually in tprocvardef.size

git-svn-id: trunk@27313 -
2014-03-28 00:40:08 +00:00
nickysn
7f88dc9d95 + added symdef.voidstackpointertype - the pointer type that will be used in the
high level code generator for obtaining references to parameters, local
  variables and temps on the stack.

git-svn-id: trunk@27308 -
2014-03-27 23:23:20 +00:00
nickysn
71720533d7 * fixed the comparison of near pointers in i8086 far data memory models
+ added charfarpointertype and charnearpointertype to symdef
* the system unit compiles in the i8086 compact memory model now

git-svn-id: trunk@27251 -
2014-03-24 00:34:52 +00:00
nickysn
97a3f50351 * use voidpointertype.size (supports i8086 far data memory models) instead of
sizeof(pint) to return the size of tabstractpointerdef

git-svn-id: trunk@27246 -
2014-03-23 20:34:19 +00:00
nickysn
043c0ba215 * use voidpointertype.size (which supports i8086 far data memory models) instead
of sizeof(pint) in tobjectdef.size and tobjectdef.alignment when returning the
  size and alignment of classes and interfaces

git-svn-id: trunk@27244 -
2014-03-23 19:36:33 +00:00
nickysn
5d9a193887 * use voidpointertype.size instead of sizeof(pint) in tarraydef in order to
determine the size of dynarrays correctly in the i8086 far data memory models

git-svn-id: trunk@27243 -
2014-03-23 18:33:14 +00:00
nickysn
ebdfbeaac8 * return voidpointertype.size instead of sizeof(pint) in tstringdef.size in
order to return the correct size in the far data i8086 memory models

git-svn-id: trunk@27241 -
2014-03-23 17:44:52 +00:00
nickysn
2556ada8da * instead of setting savesize in each of the tstringdef constructors, added an
tstringdef.size overriden method, which returns the proper size according to
  the string type

git-svn-id: trunk@27240 -
2014-03-23 17:29:10 +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
nickysn
015c7e951a * Changed the default packset setting to 1 and disabled the padding of 3-byte
sets to 4 bytes on 16 and 8-bit CPUs. This is compatible with Turbo Pascal 7
  and Delphi 1.

git-svn-id: trunk@27140 -
2014-03-14 23:51:14 +00:00
Károly Balogh
9e74fd4d33 include libsym handling for m68k as well, Amiga needs it
git-svn-id: trunk@27066 -
2014-03-10 00:32:57 +00:00
Jonas Maebe
ffac2feb59 * since we only build the deref for tprocdef.localst when we're
going to write it to the ppu since r26083, also only deref it
    if that's the case (mantis #25814)

git-svn-id: trunk@26956 -
2014-03-04 19:42:39 +00:00
nickysn
2908fa9123 + added type parentfpvoidpointertype, which is a void pointer with the same size
as the hidden parentfp parameter, passed to nested procs. On i8086 it is
  always a near pointer, unlike voidpointer (which changes according to the
  memory model). This fixes nested procs in i8086 far data memory models.

git-svn-id: trunk@26934 -
2014-03-02 22:55:52 +00:00
nickysn
75134c2a26 + default_x86_data_pointer_type implemented as function that returns the proper
type in far data memory models

git-svn-id: trunk@26928 -
2014-03-02 19:35:36 +00:00
florian
3e4198ea45 * take care of dyn. arrays in cse
git-svn-id: trunk@26740 -
2014-02-08 21:47:46 +00:00
sergei
7104157a57 * Changed tabstractprocdef.address_size to return the def, which can be used to get other properties like size and alignment. Removes one of i8086 ifdef's.
git-svn-id: trunk@26664 -
2014-02-03 10:47:54 +00:00
Jonas Maebe
2adfb6cdda * don't endlessly recurse when printing the typename of a procvardef that
refers to itself via a pointerdef in its parameter or result type(s)
    (mantis #25551)

git-svn-id: trunk@26610 -
2014-01-28 20:14:31 +00:00
Jonas Maebe
6d5bef3e1d * removed code duplication in tpointerdef.GetTypeName
git-svn-id: trunk@26609 -
2014-01-28 20:14:28 +00:00
Jonas Maebe
67413a2823 * fixed skpara setter of tprocdef after r26332
git-svn-id: trunk@26471 -
2014-01-15 20:36:49 +00:00
florian
e841027a48 * fixes handling of typed files in iso mode
git-svn-id: trunk@26436 -
2014-01-12 20:17:48 +00:00
Jonas Maebe
ab4844bdff * give an internal error when trying to set/get procdef properties that are
not available

git-svn-id: trunk@26367 -
2014-01-03 12:23:27 +00:00
Jonas Maebe
32b9926536 * don't check forwarddefs of copied record/objectdefs (there are none, since
such a def is just a renamed version of a def that's defined/implemented/
    checked elsewhere) -- fixes compiler crash when compiling webtbs/tw3930
    after r26332)

git-svn-id: trunk@26360 -
2014-01-02 16:21:06 +00:00
Jonas Maebe
32b149c622 * moved a bunch of tprocdef fields that are only required when compiling the
procdef to a dynamically allocated record that is not created when loading
    the procdef from ppu

git-svn-id: trunk@26332 -
2013-12-31 00:28:28 +00:00
sergei
258e8c58a4 + Added trecorddef.buildderefimpl, necessary since advanced records have been implemented. Fixes compiler crash on webtbs/tw18688.pp on x86_64-win64.
git-svn-id: trunk@26250 -
2013-12-18 16:26:50 +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
Jonas Maebe
9b1a36fcdb * don't call buildderef for the local symtable of procdefs unless we will
write it to the ppu

git-svn-id: trunk@26083 -
2013-11-13 20:52:38 +00:00
Jonas Maebe
c1cec52897 * fixed alignment of bitpacked arrays of ordinals/enums: the prevous code
always returned the alignment of enum/ordinal by itself, which could be
    either bigger or smaller than what was required
  * for non-bitpacked regular arrays, always use the alignment of the elements
    instead of sometimes the natural alignment of the size of the elements
    (which can be different)

git-svn-id: trunk@26019 -
2013-11-10 21:22:28 +00:00
svenbarth
798bb91e90 Extract tdef.is_related plus its overrides in tobjectdef, trecorddef and tstringdef into a new function def_is_related in unit defcmp.
defcmp.pas:
  + add new function "def_is_related" which combines the "is_related" overloads of "tobjectdef", "trecorddef" and "tstringdef" (it returns "false" for other def types which is what "tdef.is_related" did)
  * compare_defs_ext & compatible_childmethod_resultdef: change call from "x.is_related" to "def_is_related(x,...)"
symtype.pas, tdef:
  - remove "is_related" method
symdef.pas:
  - remove "is_related" in "tobjectdef", "trecorddef" and "tstringdef"
  * tobjectdef.needs_inittable: for checking whether a Corba interface somehow inherits from a IInterface don't use "is_related" anymore (we want to avoid the dependency after all), but mimic the necessary functionality of "def_is_related"
htypechk.pas, nadd.pas, ncal.pas, ncnv.pas, ngtcon.pas, nld.pas, optvirt.pas, pdecobj.pas, pdecvar.pas, pexpr.pas, pgenutil.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"
symtable.pas
  + use unit defcmp
  * change call from "x.is_related" to "def_is_related(x,...)"
jvm/njvmcnv.pas, jvm/njvmflw.pas:
  * change call from "x.is_related" to "def_is_related(x,...)"

git-svn-id: trunk@25847 -
2013-10-25 19:44:27 +00:00
svenbarth
76f6de5cf1 Refactor tobjectdef.find_implemented_interface out into unit defcmp so that the recently introduced cycle between symdef and defcmp can be broken again.
defcmp.pas:
  + add function "find_implemented_interface"
  * change method call of "find_implemented_interface" into function call
symdef.pas:
  - tobjectdef: remove method "find_implemented_interface"
  - remove use of unit "defcmp"
pgenutil.pas:
  * change method call of "find_implemented_interface" into function call
  + add use of unit "defcmp"
ncgcnv.pas, ncnv.pas, pdecobj.pas, pdecsub.pas, pdecvar.pas:
  * change method call of "find_implemented_interface" into function call

git-svn-id: trunk@25844 -
2013-10-23 19:05:00 +00:00
svenbarth
bb00c76fe7 Fix for Mantis #21015 .
symdef.pas:
  * tobjectdef.find_implemented_interface: use equal_defs to ensure that equal specializations of interfaces are found as well
  * getparaencoding: use globals.CP_NONE instead of just CP_NONE, because defcmp contains a cp_none enum as well.

+ added test

git-svn-id: trunk@25609 -
2013-09-30 08:44:46 +00:00
paul
c22c364f43 compiler: regenerate parameter list in tprocvardef.getcopy (fixes compiler crash, issue #0025077)
git-svn-id: trunk@25561 -
2013-09-25 03:28:14 +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
5aa919c2a8 compiler: have unit interface symtable in stack while parsing implementation uses list (fixes issue #10477)
git-svn-id: trunk@25505 -
2013-09-17 08:53:37 +00:00
Jonas Maebe
de56f909d5 * synchronized with trunk up to and including r25430
git-svn-id: branches/cpstrrtl@25431 -
2013-09-06 10:09:26 +00:00
Jonas Maebe
fcaad5baf2 * perform -CTlowercaseprocstart conversion it tprocsym.create rather than
when building the mangled name, because the latter can also be performed
    when compiler another unit (and therefore if that other unit's setting
    is different from that of the original unit, a wrong mangled name was
    generated) + test for this case

git-svn-id: trunk@25388 -
2013-08-29 22:43:06 +00:00
Jonas Maebe
6013606a97 + -CTlowercaseprocstart switch to lowercase the first character of routines
so that code written according to Delphi coding standards can be compiled
    into JVM bytecode with routine names conforming to JVM coding standards

git-svn-id: trunk@25385 -
2013-08-29 22:21:15 +00:00
paul
17ef986b17 compiler: don't treat methods without self node (static class methods, class contructors, destructors, operators) as method pointers, fix comparison of procdef and procvardef to allow assignment of a static class method to a regular procedural variable (issue #24486)
git-svn-id: trunk@25284 -
2013-08-18 17:29:23 +00:00
Jonas Maebe
8d1090269e * synchronised with trunk r25259
git-svn-id: branches/cpstrrtl@25267 -
2013-08-16 11:33:44 +00:00
florian
3d90ac82f8 * disable regable 4 bytes records on 16 bit alu targets, to enable them, location handling should be rewritten else gen_load_cgpara_loc gets even more messy
git-svn-id: trunk@25239 -
2013-08-11 16:12:41 +00:00
nickysn
259bb5421e * tobjectdef.vmtmethodoffset updated to take into account the current i8086 memory model code pointer size
git-svn-id: trunk@25195 -
2013-07-30 23:26:34 +00:00
svenbarth
53ea24a0b1 Correctly specialize generics if locally declared types are used (e.g. two procedures could both define a different "TRec" type which is used to specialize a generic inside the procedures).
symtype.pas, tdef:
  + add method "fullownerhierarchyname" which allows to retrieve the owner hierarchy name including procedure/function/method names
  + add method "fulltypename" which uses "fullownerhierarchyname" to return a full type name
symdef.pas, tstoreddef:
  * implement "fullownerhierarchyname" (including caching of the result)
pgenutil.pas, parse_generic_specialization_types_internal:
  * use "tdef.fulltypename" instead of "tdef.typename" to have unique values for each parsed type and thus for the specialization itself

+ tests

git-svn-id: trunk@25175 -
2013-07-26 09:02:24 +00:00
Jonas Maebe
29132f45b7 * synchronised with trunk up to r25167 (fixes glib compilation via r25164,
and occasional crashes in executeprocess on libc platforms via r25167)

git-svn-id: branches/cpstrrtl@25169 -
2013-07-24 14:24:49 +00:00
Jonas Maebe
1a560e9875 * when concatenating ansistrings, do not map CP_NONE (rawbytestring) to
CP_ACP (defaultsystemcodepage), because if all input strings have the
    same code page then the result should also have that code page if it's
    assigned to a rawbytestring rather than getting defaultsystemcodepage
  * do not consider empty strings to determine the code page of the result
    in fpc_AnsiStr_Concat_multi(), because that will cause a different
    result than when using a sequence of fpc_AnsiStr_Concat() calls (it
    ignores empty strings to determine the result code page) and it's also
    slower
  * do not consider the run time code page of the destination string in
    fpc_AnsiStr_Concat(_multi)() because Delphi does not do so either. This
    was introduced in r19118, probably to hide another bug
  + test

git-svn-id: branches/cpstrrtl@25143 -
2013-07-19 16:33:14 +00:00
sergei
8b1463aedc * tprocdef.customprocname: fixed bug introduced in r21069 that was causing result to always contain 'procedure' or 'function' word. These should be included only if pno_proctypeoption flag is given. Resolves #24640.
git-svn-id: trunk@25126 -
2013-07-17 12:41:55 +00:00
Jonas Maebe
7659bfc01b - removed internal error if savesize of tfiledef is 0 when writing the def
to the ppu file, because it does not exist on the JVM platform and
    hence will be 0 (and on other platforms, you'll get a fatal error earlier
    in case the filerec type cannot be found) (originally added as part of
    r24957)

git-svn-id: branches/cpstrrtl@24990 -
2013-06-27 21:37:32 +00:00
Jonas Maebe
5a72bc3656 * export filerec/textrec from the system unit and use them in the compiler
to determine their size, rather than hardcoding the size for all possible
    configurations

git-svn-id: branches/cpstrrtl@24957 -
2013-06-24 09:39:50 +00:00
florian
541d67771b * keep managed types in registers if possible. Under certain circumstances (if they don't require init/final code,
e.g. being a const parameter or immutable temp. values), managed types like dyn. arrays, new string types and interfaces can be kept in registers.

git-svn-id: trunk@24953 -
2013-06-23 15:16:30 +00:00
nickysn
2809ed6fb9 * updated tfiledef.setsize to support the size of textrec in the medium memory model
git-svn-id: trunk@24850 -
2013-06-09 18:22:47 +00:00
nickysn
b5c032874f * set the po_far flag by default in far code memory models
git-svn-id: trunk@24846 -
2013-06-09 17:54:29 +00:00
nickysn
b6c979e55f + added tabstractprocdef.address_size which returns the actual address size of the proc, taking into account far procs
git-svn-id: trunk@24835 -
2013-06-09 13:39:13 +00:00
nickysn
c1984bdf56 * take into account far code and far data in tprocvardef.size
git-svn-id: trunk@24823 -
2013-06-08 23:32:47 +00:00
nickysn
5966cc088d * got rid of tpointerdef.update_savesize, overrode size instead
git-svn-id: trunk@24819 -
2013-06-08 21:23:16 +00:00
nickysn
5b503f42c7 + implemented Mem/MemW/MemL[] for i8086
git-svn-id: trunk@24665 -
2013-05-31 13:31:45 +00:00
svenbarth
956b26bc97 Completely reworked implementation of generic constraints, by moving the generic constraint data from the symbols to the definitions (I originally thought that this would simplyfy things, but the more correct approach is to add it to the defs).
symsym.pas:
    - remove "tgenericconstraintdata" and any using/loading/writing of it in "ttypesym"
    - remove "tgenericconstraintflag"
symdef.pas:
    + add "tgenericconstraintdata"
    + load and write "genconstraintdata" in "tstoreddef"
symconst.pas:
    + add "tgenericconstraintflag" so it can be used in "ppudump" as well
defcmp.pas, compare_defs_ext:
    * as we allow global operator overloads we can't really determine whether two defs are compatible, because a valid operator for the specialization types might just happen to be in scope of the generic; so for now constraints are only strictly checked when declaring a specialization
pgenutil.pas:
    * adjust "parse_generic_parameters" and "check_generic_constraints" to the new location of the constraint data
ppudump.pp:
    * corrrectly parse defs which contain generic constraints

git-svn-id: trunk@24628 -
2013-05-29 08:19:02 +00:00
svenbarth
cc5a108cca Allocate the list for generic parameters in tstoreddef only on demand as most defs won't contain generic parameters anyway (avoids a little bit of runtime and memory overhead per def).
symdef.pas, tstoreddef:
  + comment that the list is allocated on demand (and thus should be checked for Nil)
  + fillgenericparas: create the list when adding at least one generic parameter symbol
  - create & ppuload: don't create list instance anymore
  + is_generic & is_specialization: check whether the list is assigned
defcmp.pas, compare_defs_ext:
  + check whether "genericparas" list is assigned
pgenutil.pas:
  + check_generic_constraints: check whether "genericparas" is assigned
  + insert_generic_parameter_types: create list before adding generic parameters

git-svn-id: trunk@24627 -
2013-05-29 07:50:49 +00:00
nickysn
e810cabf50 * set tpointerdef.savesize correctly for far and huge pointers
git-svn-id: trunk@24551 -
2013-05-22 11:54:42 +00:00
nickysn
f571aebdd0 * tx86pointertyp moved from unit symdef to symconst, so it can be used by ppudump
git-svn-id: trunk@24547 -
2013-05-21 14:18:48 +00:00
nickysn
d95c995894 - rm the commented out code of tpointerdef.createfar
git-svn-id: trunk@24546 -
2013-05-21 13:59:36 +00:00
nickysn
ae74cd17d2 * tarraydef.ppuload/ppuwrite: use ppufile.getasizeint/putasizeint for reading/writing lowrange and highrange as they're asizeint type, not aint
git-svn-id: trunk@24491 -
2013-05-13 12:37:11 +00:00
nickysn
b0f7786782 + added support for special versions of near data pointers associated with a x86 segment register. They are supported on all x86 platforms: i8086, i386 and x86_64
git-svn-id: trunk@24453 -
2013-05-05 17:22:37 +00:00
florian
0e41df598e * merge i8086 branch by Nikolay Nikolov
git-svn-id: trunk@24324 -
2013-04-25 20:23:51 +00:00
nickysn
5caadbbc40 + added method tabstractprocdef.is_pushleftright that exists on all platforms and returns whether parameters must be loaded left to right
git-svn-id: branches/i8086@24281 -
2013-04-21 09:49:34 +00:00
florian
e1233e0111 * asizeint => longint, it is unlikely that an variant record well ever have more than 2^31 branches
git-svn-id: trunk@24260 -
2013-04-16 16:49:42 +00:00