Commit Graph

194 Commits

Author SHA1 Message Date
svenbarth
7e85e27865 * fix ncgrtti correctly (for once that warning was indeed useful :P )
git-svn-id: trunk@35388 -
2017-02-04 13:46:26 +00:00
florian
4b63da81aa * initialize para to avoid warning
git-svn-id: trunk@35387 -
2017-02-04 13:30:19 +00:00
svenbarth
c1390b3442 * fix for Mantis #31249: applied (adjusted) patch provided by Maciej Izak
Commit message:
[PATCH] More consistent RTTI (also better performance) for classic
 objects (reference to initrtti from fullrtti).

git-svn-id: trunk@35376 -
2017-01-31 18:21:53 +00:00
svenbarth
f517311227 * ensure that the indirect symbols for VMT, RTTI and IID reside in the same sections as the symbols they point to -> reduces the amount of sections for them by half
git-svn-id: trunk@35367 -
2017-01-29 17:43:39 +00:00
svenbarth
1d40e7e159 * correctly encapsulate the location records
git-svn-id: trunk@35354 -
2017-01-28 16:00:53 +00:00
svenbarth
26135d605f + implement interface RTTI inspired by the changes from Steve Hildebrandt, yet not exactly the same. Like his implementation this one isn't Delphi compatible either.
+ added test

git-svn-id: trunk@35341 -
2017-01-27 17:00:15 +00:00
svenbarth
41dccb75b9 * for open array parameters the RTTI of the element def needs to be available/written; this is Delphi compatible
git-svn-id: trunk@35340 -
2017-01-27 16:55:17 +00:00
svenbarth
d044969d88 * applied adjusted patch from Mantis #31250 by Maciej Izak
Adjusted message:
 [PATCH] Remove redundant code in TRTTIWriter for get_rtti_label,
 get_rtti_label_ord2str, get_rtti_label_str2ord (use extended ref_rtti). 
 Replace ref_rtti by get_rtti_label in few places in ncgrtii (no functional 
 change).

git-svn-id: trunk@35336 -
2017-01-27 14:11:38 +00:00
svenbarth
5fa5ff1730 + new method TRTTIWriter.methods_write_rtti() to ensure that the TypeInfo of parameters and result type of methods is written (can be restricted to certain visibilities and whether hidden parameters shall be checked as well)
git-svn-id: trunk@35290 -
2017-01-13 16:25:22 +00:00
svenbarth
22e23fea8c + new parameter allow_hidden for params_write_rtti() so that writing of the TypeInfo of hidden parameters can be enforced as well
git-svn-id: trunk@35288 -
2017-01-13 16:22:42 +00:00
svenbarth
cf18b7116e * write_paralocs() takes a pcgpara instead of a tparavarsym as this is needed for the result location as well
git-svn-id: trunk@35287 -
2017-01-13 16:20:30 +00:00
svenbarth
f905303c4a + new TParamFlag pfResult if the result is passed as a parameter and thus needs to be set up as well
git-svn-id: trunk@35286 -
2017-01-13 16:17:03 +00:00
svenbarth
854a82b58b * move write_param_flag() from local to class scope
git-svn-id: trunk@35280 -
2017-01-13 13:58:55 +00:00
svenbarth
5275c36393 + extend TParamFlags by values for hidden parameters in general and especially the hidden high, self and vmt parameters (this is necessary so a manager approach for Invoke() can be used with as few knowledge about the involved calling conventions as possible)
Note: with this TParamFlags exceeds the size of a Byte

git-svn-id: trunk@35267 -
2017-01-08 16:08:35 +00:00
svenbarth
6b641394d0 * fix for Mantis #31201: don't write any RTTI for undefined defs (and while we're at it abort if an error def is encountered)
+ added test

git-svn-id: trunk@35256 -
2017-01-07 14:35:25 +00:00
svenbarth
417f1cd49d + initial implementation of the RTTI for parameter locations (not *yet* used by anything)
The parameter manager converts from the internal compiler representation of
a parameter's location to an RTTI representation. As the general implementation
more or less directly uses the compiler structures for this a platform specific
parameter manager may override this functionality in case some parameter
information changed in a non-backwards compatible way.
The RTTI parameter location has a layout that allows for an easy enumeration
as the size is fixed for all locations. Additionally there are properties that
allow for easy access to the information stored in them.

git-svn-id: trunk@35250 -
2017-01-06 22:21:37 +00:00
svenbarth
0ed00f64f5 * move writing of the calling convention into its own method
git-svn-id: trunk@35249 -
2017-01-06 20:55:25 +00:00
svenbarth
e3f10500b0 * move writing of the methodkind into its own function (and return the value as its a bit more complicated to calculate than merely checking proctypeoption)
git-svn-id: trunk@35248 -
2017-01-06 20:46:31 +00:00
florian
2e779239ad * fix rtti for targets with a max. C record alignment > 8 bytes
git-svn-id: trunk@35225 -
2017-01-03 18:44:50 +00:00
florian
0b82f71e8d * take care of the fact that there are 32 bit abis (e.g. ARMHF) which align qword on 8 byte boundaries, resolves issue #31132
git-svn-id: trunk@35218 -
2016-12-30 15:32:56 +00:00
svenbarth
7023a6f95b * have the remaining 7 Boolean types also use tkBool as typekind instead of tkInteger
git-svn-id: trunk@35186 -
2016-12-23 16:05:14 +00:00
svenbarth
dbbb6dca32 * correctly treat Boolean64 as otUQword and QWordBool as otSQWord (the former having QWord range 0..1, the latter Low(Int64)..High(Int64))
git-svn-id: trunk@35185 -
2016-12-23 16:04:12 +00:00
svenbarth
26e7d005aa * use Low(LongInt) and Max(LongInt) as min/max values for the RTTI of the ByteBool, WordBool and LongBool types to be Delphi compatible; the range of the defs is not changed to avoid the application of range checks
git-svn-id: trunk@35184 -
2016-12-23 16:01:59 +00:00
Jonas Maebe
d8c4980b2e * don't reuse the same type with the typed const builder for
differently-sized types

git-svn-id: trunk@35153 -
2016-12-18 13:57:15 +00:00
Jonas Maebe
691c2d655e * put multiple statements of the else-part of case between begin..end
git-svn-id: trunk@35152 -
2016-12-18 13:57:12 +00:00
Jonas Maebe
fe6b662c37 * fixed range error
git-svn-id: trunk@35151 -
2016-12-18 13:57:09 +00:00
Jonas Maebe
bcb7fedb3c * fixed indentation
git-svn-id: trunk@35150 -
2016-12-18 13:57:06 +00:00
svenbarth
86207c9b55 - remove no longer valid {otNone} comment
git-svn-id: trunk@35136 -
2016-12-16 14:23:14 +00:00
svenbarth
a9d14fe30b * extend TOrdType by entries for 64-bit values
* have tkInt64 and tkQWord entries also contain the OrdType field (basically the compiler can now use the same function to generate them only with different type kinds)

+ added test

git-svn-id: trunk@35135 -
2016-12-16 14:22:04 +00:00
svenbarth
7089677a22 * change RecInitTable into a direct reference to avoid an unnecessary indirection as both the full and init RTTI of a record always reside inside the same unit
git-svn-id: trunk@35128 -
2016-12-14 18:40:16 +00:00
svenbarth
e580e22576 * extend ref_rtti() with the possibility to use a direct reference if really desired
git-svn-id: trunk@35127 -
2016-12-14 18:38:54 +00:00
svenbarth
12dba952f0 * integration of Part 2 patch of Mantis #30687 with a few adjustments:
- indentation in ncgrtti.pas
  - fewer ifdefs in rtti.inc
  - InitTable/Terminator field as first field to avoid padding on targets that require proper alignment and have SizeOf(Pointer) > 4

Original message by Maciej Izak:

Breaking change for rtti layout for record rtti. Init table
is always accessible from regular rtti. Rtti table contains indirect
reference to init table, additionally init table contains nil-terminator (for
rtl purposes - the only way to determine kind of info : init or rtti). Pros:

* will be possible to create more Delphi compatible code for RTTI, finally end-user can access to *real* managed fields of records (some work on TypInfo.pp is still required but is not necessary).
* important step forward for management operators (anyway this commit is not directly related to management operators)
* much more optimal memory allocation/initialization/finalization for records created/destroyed by InitializeArray/FinalizeArray, for example:

type
  TBar = record
    f1,f2,f3,f4,f5,f6,f7,f8,f9: byte;
    s: string;
  end;

previously:

  GetMem(PB, SizeOf(TBar));
  InitializeArray(PB, TypeInfo(TBar), 1); // FPC_INITIALIZE was executed 10 times

now:

  GetMem(PB, SizeOf(TBar));
  InitializeArray(PB, TypeInfo(TBar), 1); // FPC_INITIALIZE is executed just once

+ test attached

git-svn-id: trunk@35125 -
2016-12-13 23:03:11 +00:00
Jonas Maebe
5efb32285a * fixed alignment for interface RTTI (patch by Alfred, mantis #30182)
git-svn-id: trunk@34695 -
2016-10-09 12:34:01 +00:00
Jonas Maebe
4c9903455e - don't apply const_align() to alignments passed to high level typed
constant builder, it will do so itself if necessary

git-svn-id: trunk@34632 -
2016-10-06 06:25:02 +00:00
nickysn
8672d25e9a * use tai_const.create_nil_dataptr instead of .create_pint(0) when writing the
leading nils in the enum rtti in lookup mode

git-svn-id: trunk@34626 -
2016-10-04 21:15:36 +00:00
nickysn
4dc35b0996 * use sizeint when writing the element size and count for the array rtti
git-svn-id: trunk@34624 -
2016-10-04 17:38:18 +00:00
Jonas Maebe
ae51adac18 * give names to the types of the fields of the enumdef rtti, so that we can
refer to these type names when writing the s2o and o2s arrays in the LLVM
    assembler writer (otherwise we have to write out the entire definition
    of those fields and their subtypes for every access, resulting in a 139MB
    cpubase.ll instead of a more reasonable 1.5MB one now)

git-svn-id: trunk@34386 -
2016-08-28 22:07:47 +00:00
svenbarth
f50671fe44 * reference the RTTI assembler symbols if they're queried from a different unit than the own they're declared in
git-svn-id: trunk@34347 -
2016-08-19 14:54:28 +00:00
svenbarth
50865158a4 Fix for Mantis #30410.
* ncgrtti.pas, TRTTIWriter.ref_rtti: don't require the indirect symbol as an external assembler symbol, but the direct one

git-svn-id: trunk@34221 -
2016-07-29 13:49:42 +00:00
svenbarth
f69b365b77 * declare various symbols as external assembler symbols: RTTI references, parent VMT, FPC_EMPTYMETHOD (all three only if it's used from a different unit), threadvar lists and symbols declared as "external"
git-svn-id: trunk@34176 -
2016-07-22 13:34:38 +00:00
svenbarth
bb72c1c4df * declare various assembler symbols (VMT, RTTI, threadvars) as public assembler symbols
* declare public function alias as public assembler symbols

git-svn-id: trunk@34175 -
2016-07-22 13:11:24 +00:00
Jonas Maebe
a0efde8167 * automatically generate necessary indirect symbols when a new assembler
symbol is defined
   o removed all places where AB_INDIRECT symbols were explicitly generated
   o only generate AB_INDIRECT symbols for AT_DATA on systems_indirect_var_imports
   o for some symbols an indirect symbol is always required (because they are
     dereferenced by code in RTL units) -> use new AT_DATA_FORCEINDIRECT type

git-svn-id: trunk@34165 -
2016-07-20 20:53:03 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +00:00
svenbarth
345d83c3e3 Merge RTTI changes from packages branch (including adjustments that were required due to changes in trunk since then). These changes favor source backwards compatibility in contrast to Delphi compatibility. Binary compatiblity is however drastically broken due to the indirect references that are platform independant!
Merged revision(s) 28239-28289 from branches/svenbarth/packages:
Provide the possiblity to switch between the direct and indirect RTTI symbols.

ncgrtti.pas, TRTTIWriter:
  + get_rtti_label, get_rtti_label_ord2str & get_rtti_label_str2ord: add new "indirect" parameter and pass that along to rtti_mangledname
hlcgobj.pas, thlcgobj:
  * g_incrrefcount, g_initialize, g_finalize, g_array_rtti_helper: for now pass along False to get_rtti_label()
ncgvmt.pas, TVMTWriter:
  * writevmt: for now pass along False to get_rtti_label()
ncgld.pas, tcgrttinode:
  * pass_generate_code: for now pass along False to the get_rtti_label*() methods
........
Provide possibility to select between using a direct and an indirect RTTI reference. This way the references can be changed for selected cases.

ncgrtti, TRTTIWriter:
  * ref_rtti: new "indirect" parameter that's relayed to rtti_mangledname()
  * write_rtti_reference: new "indirect" paramater that's relayed to ref_rtti()
........
Switch properties to use the indirect type information without breaking backwards compatiblity. :)

compiler/ncgrtti.pas, TRTTIWriter:
  * published_properties_write_rtti_data: use the indirect reference, not the direct one
rtl/objpas/typinfo.pp:
  * to allow compilation with both 2.6.x and 2.7.1 and too avoid too many ifdefs at least in the declarations we define a macro TypeInfoPtr which is either PTypeInfo (2.6.x) or PPTypeInfo (2.7.1 and newer)
  * TPropInfo: rename PropType to PropTypeRef and change type to TypeInfoPtr
  + TPropInfo: add a new property PropType which returns a PTypeInfo out of the PropTypeRef depending on the compiler version
........
Switch further simple types (sets, enums, class references, pointers) to indirect type information (again without breaking backwards compatibility).

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data:
  * enumdef_rtti, setdef_rtti, classrefdef_rtti & pointerdef_rtti: write an indirect RTTI reference

rtl/objpas/typinfo.pp, TTypeData:
  * rename BaseType to BaseTypeRef, CompType to CompTypeRef, InstanceType to InstanceTypeRef and RefType to RefTypeRef and change their type to TypeInfoPtr
  + add properties BaseType, CompType, InstanceType & RefType which return a PTypeInfo out of the corresponding *Ref field depending on the compiler version
........
Switch class and interface parent as well as extended type to indirect type information

compiler/ncgrtti.pas, TRTTIWriter:
  * write_rtti_data.objectdef_rtti.objectdef_rtti_class_full: use indirect reference for class parent and extended type
  * write_rtti_data.objectdef_rtti.objectdef_rtti_interface_full: use indirect reference for interface parent

rtl/objpas/typinfo.pp, TTypeData:
  + add new method DerefTypeInfoPtr which returns Nil if the indirect reference is Nil and otherwise returns the dereferences indirect reference (for 2.6.x the direct reference is returned as is)
  * rename ParentInfo to ParentInfoRef, HelperParent to HelperParentRef, ExtendedInfo to ExtendedInfoRef, IntfParent ot IntfParentRef and RawIntfParent to RawIntfParentRef and change their type to TypeInfoPtr
  + introduce ParentInfo, HelperParent, ExtendedInfo, IntfParent and RawIntfParent properties that return a PTypeInfo and use the new DerefTypeInfoPtr to return the correct type info value
  * change the other newly introduced properties of TTypeData to use DerefTypeInfoPtr as well to be on the safe side
........
Switch record/object fields to indirect type information references.

compiler/ncgrtti.pas, TRTTIWriter.fields_write_rtti_data:
  * use the indirect reference for the object parent type
  * use the indirect reference for the field type

rtl/inc/rtti.inc:
  * TRecordElement: change TypeInfo to PPointer for 2.7.1 and newer
  * RecordRTTI: correctly dereference the element type for 2.7.1 and newer
  * fpc_copy: correctly reference the element type for 2.7.1 and newer
........
Switch static arrays to indirect RTTI reference.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data:
  * arraydef_rtti: write the dimension types and the final field type as indirect references

rtl/inc/rtti.inc:
  * TArrayInfo: switch ElInfo to PPointer for 2.7.1+
  * ArrayRTTI & fpc_copy: correctly dereference ElInfo for 2.7.1+
rtl/objpas/typinfo.pp, TArrayTypeData:
  * switch ElType and Dims to PPTypeInfo; no backwards compatibility needed here as TArrayTypeData was added in 2.7.1 only

tests/test/trtti8.pp: fix test
........
Switch dynamic arrays to indirect RTTI references.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data.arraydef_rtti:
  * write indirect references for the two element entries

rtl/inc/dynarr.inc:
  * tdynarraytypedata: change elType2 to PPointer for 2.7.1+
  * fpc_dynarray_clear, fpc_dynarray_setlength & fpc_dynarray_copy: correctly dereference elType2 for 2.7.1+
rtl/objpas/typinfo.pp, TTypeData:
  * rename elType and elType2 to elTypeRef and elType2Ref respectively and change type to TypeInfoPtr
  * add properties elType and elType2 which return PTypeInfo by dereferencing elTypeRef and elType2Ref respecively correctly
  * remove a few stray "inline" directives in the implementation
........
Switch procedure parameters and result type to indirect RTTI references.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data.procvardef_rtti:
  * write_procedure_param: use indirect RTTI reference
  * write result info for both methods and procvars as indirect RTTI reference
  * write parameters for procvars as indirect RTTI reference

rtl/objpas/typinfo.pp:
  * TProcedureParam: change type of ParamType to PPTypeInfo (no backwards compatiblity needed here; was added for 2.7.1)
  * TProcedureSignature: change type of RseultType to PPTypeInfo (no backwards compatibility needed here; was added for 2.7.1)
  * TTypeData: remark in the comments of tkMethod that ResultTypeRef and ParamTypeRefs are of type PPTypeInfo and not PTypeInfo

tests/test/trtti9.pp: 
  * fix test
........
Remove no longer needed "indirect" parameter for TRTTIWriter methods.

ncgrtti.pas, TRTTIWriter:
  - ref_rtti & write_rtti_reference: remove "indirect" parameter
  * ref_rtti: call rtti_mangledname with "indirect" always set to "true"
  - remove "true" parameter on callsites of write_rtti_reference & ref_rtti
........

git-svn-id: trunk@33944 -
2016-06-10 17:01:51 +00:00
svenbarth
140f5b5f94 Write indirect symbols for the RTTI (basically a merge of r28238, but using the typed constant builder and the new indirect asmbinds)
ncgrtti.pas, TRTTIWriter:
  * write_rtti & write_rtti_extrasyms: generate an indirect symbol for each of the RTTI symbols (they are not used yet, but soon will be)
  * write_rtti: reorder operations a bit: first free the tcb (we don't need it anymore), then write the indirect symbol and only then write any extra symbols that might be needed (this way the RTTI data and the indirect symbol will be next to each other)
  

git-svn-id: trunk@33447 -
2016-04-08 13:39:04 +00:00
florian
cb4773432b + hardfloat directive (arm only): use hard float calling conventions regardless of the abi, resolves #29715
git-svn-id: trunk@33196 -
2016-03-06 15:47:31 +00:00
svenbarth
8152d1185c Only write the IIDStr for Corba interfaces (it's completely redundant for COM ones)
ncgrtti.pas, TRTTIWriter.write_rtti_data.objectdef_rtti.objectdef_rtti_interface_full:
  * only set the ifHasStrGUID flag for Corba interfaces and if the IIDStr is not '' (which it is by default)
  * only write the IIDStr for Corba interfaces

git-svn-id: trunk@33105 -
2016-02-19 15:22:46 +00:00
Jonas Maebe
5aadb149ed * ensure the types of all elements emitted in all paths through
writeaccessproc() are the same, so the reuse of existing defs doesn't
    result in the generation of typecasts for llvm

git-svn-id: trunk@32903 -
2016-01-10 14:01:43 +00:00
Jonas Maebe
5201547043 * don't reuse defs when writing RTTI for stored properties, as their layout
depends on how exactly they are stored

git-svn-id: trunk@32757 -
2015-12-27 11:14:41 +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
94a6ef3103 * use codeptruinttype/codeptrsinttype when emiting ordinal constants that
have the same size as voidcodepointertype

git-svn-id: trunk@32473 -
2015-11-22 11:49:43 +00:00
Jonas Maebe
c2caa6641c * free typedconstbuilder after generating rtti
git-svn-id: trunk@32201 -
2015-10-30 14:17:13 +00:00
Jonas Maebe
8c90941d89 * use the enymsym's name rather converting its symid to a string when creating
the rtti record's fields

git-svn-id: trunk@32150 -
2015-10-25 19:21:51 +00:00
svenbarth
3afc18f277 Fix for Mantis #28766.
ncgrtti.pas, write_persistent_type_info:
  * do not generate RTTI information for generics

git-svn-id: trunk@31911 -
2015-10-02 13:06:51 +00:00
yury
432248cbf1 * Removed lot of unused vars.
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
Jonas Maebe
be2ec5be59 * write full/init rtti and VMTs separately instead of at the same time
o this allows us to write the VMTs earlier (before the synthetic method
     implementations are generated), which means we can create new synthetic
     methods while generating the VMTs (for interface trampolines)

git-svn-id: trunk@31635 -
2015-09-12 23:32:38 +00:00
Jonas Maebe
4c0807c596 * simplified enum lookup table management by using tfplist instead of
an ad hoc dynamic array implementation

git-svn-id: trunk@31295 -
2015-08-06 18:34:31 +00:00
Jonas Maebe
d7f6744f7b * converted ncgrtti to the high level typed constant builder
o the result is still not very clean due to the fact that this data
     is almost completely unstructured due to variable-length strings
     everywhere, which means that
    a) we cannot just load recorddefs from the system or typeinfo unit
       and use those as templates
    b) we cannot easily reuse the recorddefs we create ourselves (except
       if the strings have the same length -- this is the reason for all
       of the names specified to begin_anonymous_record: to reuse defs
       as much as possible rather than creating new ones all the time)
    c) we have to add explicitly aligned subrecords everywhere to insert
       explicit alignment on platforms that need it

git-svn-id: trunk@31255 -
2015-07-30 16:58:17 +00:00
nickysn
d1ac1bf1e0 * fixed writing rtti published property getter/setter/stored proc info in the
i8086 far code/data memory models

git-svn-id: trunk@28726 -
2014-09-30 01:47:17 +00:00
nickysn
2e0707f465 * fixed writing of dynarray rtti in the i8086 far data memory models
git-svn-id: trunk@28707 -
2014-09-22 16:12:11 +00:00
sergei
7e1c370c17 * Write RTTI for function arguments as children of function RTTI, resolves #24540,#25002,#25128 (bugs are basically duplicate, so adding only first of them to the testsuite).
git-svn-id: trunk@27797 -
2014-05-16 20:09:32 +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
088c06d308 * fixed class VMT generation for the i8086 medium memory model (near code, far data) by setting correctly the Tasmsymtype to each symbol according to whether it points to code or data
git-svn-id: trunk@25276 -
2013-08-18 00:03:55 +00:00
nickysn
875e676441 * use Create_nil_dataptr in objectdef_rtti_class_full() when writing the current vmt address for objects that have no vmt
git-svn-id: trunk@25200 -
2013-07-31 15:10:46 +00:00
nickysn
f7d3f7cd33 * use create_nil_dataptr instead of create_sym(nil) in TRTTIWriter.write_rtti_reference; among other things, this fixes writeln(enum) in the i8086 medium memory model
git-svn-id: trunk@24977 -
2013-06-25 21:02:55 +00:00
paul
5ff7bb884e compiler: don't skip objc class/protocols in case of initrtti, fixed crash of dynamic array/record which contains a objc class/protocol and requires an initialization
git-svn-id: trunk@24723 -
2013-06-01 14:45:10 +00:00
sergei
23cb216435 * RTTI fix for alignment-sensitive targets:
* typinfo.pp: the newly introduced records were added into {$PACKRECORDS 1} area of effect, which  effectively made all records packed, entirely defeating FPC_REQUIRES_PROPER_ALIGNMENT purpose. 
  * added alignment between TProcedureParam records, adjusted TProcedureSignature.GetParam() appropriately.
   * ncgrtti.pas: added two missing alignments and removed a redundant one.
   * tests/test/trtti9.pp: modified to use TProcedureSignature.GetParam() and endian-independent check for parameter flags.

git-svn-id: trunk@24562 -
2013-05-23 16:03:42 +00:00
paul
b333ef582b compiler: don't treat array[..] of dynamic array as a 2 dimension array
git-svn-id: trunk@24522 -
2013-05-17 01:08:27 +00:00
paul
980bc634b4 compiler:
- add write_rtti_reference method, 
  - minor refactoring, 
  - always write nil as RTTI reference for objc types and void types

git-svn-id: trunk@24471 -
2013-05-08 05:47:48 +00:00
paul
fceb6c3cc5 compiler: skip objc types in ProcVar rtti arguments and result type
git-svn-id: trunk@24470 -
2013-05-08 03:40:01 +00:00
paul
bc973e538d compiler: write extended RTTI for tkProcVar (tkProcedure in Delphi)
rtl: add appropriate types for tkProcVar RTTI (based on Delphi help)
+ test

git-svn-id: trunk@24468 -
2013-05-08 02:52:13 +00:00
paul
fe04dedbab compiler: change RTTI size of record field offset from fixed 32bit to platform dependent integer (sizeint) since it is stored this way in the compiler. This is also Delphi compatible, rtl: adopt rtl appropriately
git-svn-id: trunk@24460 -
2013-05-07 11:25:41 +00:00
paul
5f709430d4 compiler: fix indentation
git-svn-id: trunk@24459 -
2013-05-07 10:39:47 +00:00
paul
dce960c97b compiler: write Delphi compatible tkArray RTTI:
- TotalSize of all array dimensions instead of first dimension size
  - Element type of last array dimension
  - dimension information
rtl:
  - adopt array initialization/finalization/copy for the new tkArray RTTI
  - add Delphi compatible TArrayTypeData member for typinfo.TTypeData structure
tests:
  - add a test which checks RTTI information for 2 dimension array

git-svn-id: trunk@24458 -
2013-05-07 09:12:18 +00:00
paul
39cee28f01 compiler: don't write reference to objc classes/protocols when writing tkClassRef rtti
git-svn-id: trunk@24454 -
2013-05-06 13:12:09 +00:00
paul
da35b3c601 compiler, rtl: write CodePage for AnsiString RTTI (Delphi compatible), change TTypeData appropriately + test
git-svn-id: trunk@24444 -
2013-05-05 05:05:08 +00:00
paul
714511a4d9 compiler: typo
git-svn-id: trunk@24441 -
2013-05-05 03:46:42 +00:00
paul
5cd3f9d8fb compiler: don't write rtti for objc classes/protocols (a trial to fix build on mac)
git-svn-id: trunk@24440 -
2013-05-05 03:18:59 +00:00
paul
2cbc061707 compiler: write rtti for pointeddef before classrefdef and pointerdef rtti
git-svn-id: trunk@24429 -
2013-05-04 17:12:52 +00:00
paul
d18f273f67 compier, rtl: revert 24424 since it fails on some platforms
git-svn-id: trunk@24425 -
2013-05-04 16:16:30 +00:00
paul
e23534eec4 compiler, rtl: some rtti related changes:
- write pint instead of 32 bit for record field offset (compiler uses aintsize = pint in TRecordDef), use PtrInt in RTL for record reading
  - add tkRecord to TTypeData (field and type names are taken from Delphi help)
  - add tkProcedure as alias to tkProcVar

git-svn-id: trunk@24424 -
2013-05-04 16:05:04 +00:00
paul
d90445e5ee compiler, rtl, tests: write Delphi compatible (more or less) type information for Class Reference and Pointer types (mantis #0024367)
git-svn-id: trunk@24421 -
2013-05-04 12:47:05 +00:00
pierre
78d31eb3cd Add missing of pi_needs_got found by sparc compiler compiled with -dCHECK_PIC
git-svn-id: trunk@22548 -
2012-10-05 15:02:47 +00:00
Jonas Maebe
4cae00f97a * never use a linear table for enum<->string translation when two enums have
the same value (mantis #22570)

git-svn-id: trunk@22276 -
2012-08-31 18:51:59 +00:00
sergei
a54e342060 + Reduce the amount of RTTI by not generating 'init' information if it will end up being the same as the 'full' one (which is the case of most simple types). The new behavior can be customized for every tdef by overriding needs_separate_initrtti method.
git-svn-id: trunk@21077 -
2012-04-27 10:17:59 +00:00
Jonas Maebe
22dd93858d * don't try to write rtti for fields in Pascal records/classes/objects/...
whose type is an objc type (objcclass, objcprotocol): they only need
    objc-style rtti, which is generated elsewhere (and to prevent bugs
    they give an internal error if we try to generate FPC-style rtti for
    them) (mantis #20876)

git-svn-id: trunk@19861 -
2011-12-17 11:43:13 +00:00
florian
d35d1ed357 + initial support for pascal booleans with sizes 2, 4 and 8
git-svn-id: branches/pasboolxx@17836 -
2011-06-26 15:02:37 +00:00
paul
937bf3cdaf compiler: write finished zero for enumeration rtti (this was broken since r14511 fixes bug #0019288)
git-svn-id: trunk@17407 -
2011-05-05 08:52:14 +00:00
svenbarth
35b47e491c Rebase to revision 17306
git-svn-id: branches/svenbarth/classhelpers@17314 -
2011-04-13 10:04:14 +00:00
florian
3ce9ff93f1 + patch by Jeppe Johansen to support automatic interrupt table generation by using the interrupt directive with an offset. Not activated yet because it requires to change also the startup code of the different mcus.
git-svn-id: trunk@17279 -
2011-04-10 15:59:06 +00:00
svenbarth
b0b051ae83 Introduce a new type kind for helpers in the RTTI. This is Delphi incompatible, but it's cleaner than Delphi's "let's extend some magic class". This might not matter much though, because according to Google the RTTI for class helpers seems to be rarely used.
* compiler/ncgrtti.pas:
- objectdef_rtti_class_full:
 - don't write the VMT data for helpers
 - write the typeinfo of the extended type (something that Delphi does definitely not support :P )
- objectdef_rtti: write the new type kind for helpers instead that of classes
* compiler/symconst.pas: introduce new type kind constant "tkHelper" before "tkFile" (what is that used for btw?)
* rtl/inc/system.inc: add the constant here as well (why wasn't tkUChar added here?)
* objpas/typinfo.pp: 
- add tkHelper to the TTypeKind enum (but here tkUChar was added?!)
- extend the TTypeData record with the data of helpers

git-svn-id: branches/svenbarth/classhelpers@17240 -
2011-04-03 14:13:00 +00:00
svenbarth
96116a6c3a Several adjustments because virtual methods in helpers are just normal methods and a VMT isn't generated for them either.
* $CPU/cgcpu.pas: disable the generation of VMT loading code
* dbgstabs.pas, dbgdwarf.pas: treat virtual methods of helpers as normal methods
* ncgcal.pas: don't register virtual helper methods for WPO 
* ncgrtti.pas: write virtual helper methods as normal methods to RTTI
* nobj.pas: correctly handle final and override cases in helpers
* pdecvar.pas: property getters
* rautils.pas: no VMT offset in records

git-svn-id: branches/svenbarth/classhelpers@17150 -
2011-03-20 10:41:45 +00:00
svenbarth
5218666328 * ncgrtti.pas: RTTI generation for helpers is handled like that for classes
* pdecl.pas: prohibit generic helper declarations
* pdecobj.pas: helpers extending generic types are not allowed (theoretically one could experiment with allowing this for Delphi style generics...)
* symtable.pas:
- is_visible_for_object: helpers can access (strict) protected fields of extended types
- searchsym_in_helper: use the correct contextclass and the correct search function
- search_default_property: search for default properties in helpers first
* symsym.pas: added a global variable that allows to track whether we are parsing inside a special system function
* pexpr.pas:
- statement_syssym: track the current syssym
- factor.factor_read_id: helper types are allowed inside "sizeof", "bitsizeof" and "typeinfo"

git-svn-id: branches/svenbarth/classhelpers@17097 -
2011-03-09 15:42:38 +00:00
svenbarth
963a4d7b23 Commit of a completely restructured helper implementation. Instead of changing objectdefs with odt_classhelper to odt_class, they'll have the odt_helper type assigned to and this will be kept. This also implies that the parent of a helper is its true parent while the extended type is set to a field in tobjectdef (extendeddef).
This change became necessary of the following reasons:
- Records don't support inheritance, thus for "record helpers" some creativity would have been necessary to implement them; with the new implementation this is more easily
- the new approach allows for easy checks regarding virtual methods and their overrides which would have been more complicated in the old variant
- if someone feels the need the types of helpers (object, interface) can be added rather easily
- unnecessary things like VMT generation can be disabled now

details:
- msg*: 
* moved some messages from parser to type
* adjusted a message ("class helper" => "helper")
- symdef.pas:
* renamed "helperparent" to "extendeddef" and changed its type from "tobjectdef" to "tabstractrecorddef", so records can be extended as well (somewhen in the near future)
* removed "finish_class_helper" method as it isn't necessary (luckily I haven't yet adjusted the ObjC variant)
* changed name of "is_objectpascal_classhelper" to "is_objectpascal_helper" to reflect that this function applies to all helper types
* tobjectdef.create: ImplementedInterfaces isn't created for odt_helper anymore
* tobjectdef.alignment: for helpers it's the same as for classes although this shouldn't be used anywhere...
* tobjectdef.vmtmethodoffset: set to 0 for helpers to be sure...
* tobjectdef.needs_inittable: not needed for helpers (no fields allowed)
* is_objectpascal_helper: only needs check for "odt_helper" object type
- symconst.pas:
* changed odt_classhelper to more general odt_helper
* added new type "thelpertype" which is used to check that "(record|class) helper" corresponds with the given extended type (as Delphi XE checks this as well this strict solution can be kept for modes Delphi and ObjFPC)
- symtable.pas:
* extended "searchsym_in_class" with the possibility to disable the search for helper methods (needed for inherited) => this implies changing all occurences of "searchsym_in_class" with a "true" except some special locations
* renamed "search_objectpascal_classhelper" to "search_objectpascal_helper"
* searchsym_in_class: 
** when an extended method is defined with "overload" it can be that a same named method of the extended class might be called (sadly this means that this search was unnecessary...)
** contextclassh is the def of the helper in the case of an inherited call inside the helper's implementation
** when methods inside a helper are searched, it must be searched in the extended type first
- ptype.pas:
* single_type is used to parse the parent of a helper as well, so allow a helper if the stoParseClassParent is given (needs check in pdecobj.pas/parse_class_parents for normal classes)
* read_named_type: currently the only case when something <> ht_none is passed to the modified parse_objdec (see below) is when the combination "class helper" is encountered ("record helper" will be another one)
- pinline.pas: adjustment for extended "searchsym_in_class"
- pexpr.pas:
* adjustments regarding "searchsym_in_class" and "is_objectpascal_helper"
* factor/factor_read_id: moved the check for "TSomeClassType.SomeMethod" outside of the "is_class" check
* factor: 
** in case of an inherited we need to search inside the extended type first (Note: this needs to be extended to find methods in the helper parent if no method is found in the extended type)
** we also need to disable the search for helper methods when searching for an inherited method (Note: it might be better to introduce a enum to decide whether a helper method should search before or after the methods of the extended type or even never)
- pdecsub.pas:
* insert_self_and_vmt_para: in a helper the type of Self is of the extended type
* pd_abstract, pd_final: more nice error message
* pd_override, pd_message, pd_reintroduce: adjusted checks because now "is_class" is no longer true for helpers
* proc_direcdata: allowed "abstract" for helpers (only to produce a more nice error message)
* parse_proc_direc: adjustment because of "is_objectpascal_helper"
- pdecobj.pas:
* adjustments regarding "is_objectpascal_helper"
* adjusted object_dec to take the type of the helper (class, record) as a parameter to be able to check whether the correct extended type was given
* struct_property_dec: properties are allowed in helpers
* parse_object_options: nothing to be parsed for helpers (at least I hope so ^^)
* parse_parent_classes: 
** the parent of a helper is now parsed as a normal parent, the extended type is parsed in an extra procedure
** check for "sealed" no longer needed
** added check that the parsed parent of a helper is indeed a helper
** allow to parse the closing ")" of the helper's parent
* parse_extended_class:
** new procedure that parses the type which is extended
** it checks that the extended type is a class for "class helper" and a record for "record helper"
** it checks that a helper extends the same class or a subclass for class helpers
** it checks that a helper extends the same record for record helpers
* parse_object_members:
** "type", "const", "var" is allowed in helpers
** don't exclude flags regarding virtual methods, they are needed for the checks in mode Delphi (this implies that VMT loading must be disabled for helpers)
* object_dec:
** don't change "odt_helper" to "odt_class", but still include the "oo_is_classhelper" flag
** allow the parsing of object options (there are none)
** parse the extended type for helpers
- pdecl.pas
* adjustment because of extension of object_dec
* types_dec: remove the call to finish_classhelper
- objcdef.pas
* objcaddencodedtype, objcdochecktype: add references to helpers as implicit pointers although that should not be used in any way...
- nld.pas
* tloadnode.pass_typecheck: self is a reference to the extended type
- nflw.pas
* create_for_in_loop: adjustment because of changed procedure and inheritance type
- ncgrtti.pas
* TRTTIWriter.write_rtti_data: disable for helpers for now (I need to check what Delphi does here)
- ncgld.pas
* tcgloadnode.pass_generate_code: virtual methods of helpers are treated as normal methods
- ncgcal.pas
* tcgcallnode.pass_generate_code: virtual methods of helpers are treated as normal methods
- ncal.pas
* tcallnode.pass_typecheck: adjust for extension of tcallcandidates constructor
- htypechk.pas
* tcallcandidates declaration: extend some methods to (dis)allow the search for helper methods (needed for inherited)
* tcallcandidates.collect_overloads_in_struct: 
** search first in helpers for methods and stop if none carries the "overload" flag
** move the addition of the procsyms to an extra nested procedure because it's used for helper methods and normal struct methods

git-svn-id: branches/svenbarth/classhelpers@16947 -
2011-02-20 11:41:55 +00:00
paul
89dc742de2 compiler: mark operator overloads as operators in rtti (although classes don't have operator overloads now)
git-svn-id: trunk@16667 -
2010-12-31 02:24:22 +00:00
sergei
2ff5f7a000 * For object fullrtti, add a parent 'field' regardless of whether its type needs inittable.
git-svn-id: trunk@16635 -
2010-12-24 16:20:44 +00:00
sergei
8cbef5627e Fixed rtti/finalization of objects that have ancestors and fields of managed types:
* Link rtti to ancestor by writing rtti of ancestor as a field of type tkObject and offset zero. This is a cheat from formal point of view (as it replaces inheritance with aggregation), but is fine for the intended purpose of representing memory layout. Now RTL can handle entire instance of descendant object, and such objects can be statically allocated without leaks.
* Bypass finalization in inherited object destructors, as the instance is now entirely finalized in outermost destructor.
+ test

git-svn-id: trunk@16632 -
2010-12-24 14:46:29 +00:00
sergei
cd1f8e14f4 * TRTTIWriter improvements:
* Emit typename for Variants (Delphi compatible)
  * For objects, write record-style RTTI instead of class-style. Objects cannot have published symbols, so class-style RTTI for them is always empty, thus typeinfo() was returning a useless stub. The new behavior is closer to Delphi, but still different (Delphi typeinfo() returns pointer to what is initrtti in FPC, while we return fullrtti).

git-svn-id: trunk@16612 -
2010-12-22 14:45:40 +00:00
sergei
b50cf9a42a * TRTTIWriter.fields_write_rtti_data: refactoring. Since TAsmList allows random access, a separate loop iteration to count fields is redundant. Simply count the actually written fields, then insert result before field data.
git-svn-id: trunk@16611 -
2010-12-22 12:42:16 +00:00
sergei
b3aa9ac813 * Refactored TRTTIWriter by separating some commonly used code into procedures. Improves readability and reduces amount of typing; functionality stays unchanged.
git-svn-id: trunk@16607 -
2010-12-21 22:33:48 +00:00