Commit Graph

855 Commits

Author SHA1 Message Date
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
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
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