Commit Graph

208 Commits

Author SHA1 Message Date
Károly Balogh
ea635bfda5 typinfo: push/pop doesn't save packrecords. also, always use AlignTypeData on m68k, which might have less than pointer sized (word, 2 byte) alignments in the typeinfo, because on most systems C compilers also use 2 byte alignments, so we need that for compatibility
git-svn-id: trunk@36594 -
2017-06-24 23:18:12 +00:00
michael
ac207e867b * Fix bug ID #30952
git-svn-id: trunk@35900 -
2017-04-22 12:40:51 +00:00
maciej-izak
3900ccf260 * Rename RecordOp to ManagementOp (more relevant name)
git-svn-id: trunk@35453 -
2017-02-19 18:06:54 +00:00
maciej-izak
af8e0efe57 * Rtti info about Management Operators (MO) in init table for records. Note: commit contains minimal changes for RTL (for proper "make") no functional changes. More RTL changes for fully functionally MO in next commits.
compiler/ncgrtti.pas
  + write_record_operators procedure which fills simple VMT like table for MO.
  * recorddef_rtti save MO (if exists)
  * objectdef_rtti_fields save nil pointer/entry for objects rtti (have same RTL parts like for records)

compiler/options.pas
  + new define FPC_HAS_MANAGEMENT_OPERATORS

compiler/symconst.pas
  + new item itp_init_record_operators for tinternaltypeprefix enum
  + new entry '$init_record_operators$' in internaltypeprefixName

rtl/inc/rtti.inc
  + new field RecordOp (pointer to MO VMT table) in TRecordInfoInit
  + new types to handle MO VMT: TRTTIRecordOpVMT, PRTTIRecordOpVMT, TRTTIRecCopyOp, TRTTIRecVarOp

rtl/objpas/typinfo.pp
  + RecordOp field for TRecInitData record

git-svn-id: trunk@35445 -
2017-02-19 00:22:59 +00:00
svenbarth
870bffc70d * provide access to the method table for raw interfaces (it is written even though $M is not respected by such interfaces currently)
git-svn-id: trunk@35411 -
2017-02-10 16:03:57 +00:00
svenbarth
fd1047c715 * use the correct alignment for the field following the unit name of an interface (raw or not doesn't matter)
git-svn-id: trunk@35410 -
2017-02-10 16:02:23 +00:00
svenbarth
060cb62f2a * correctly handle alignment for TParameterLocations
git-svn-id: trunk@35355 -
2017-01-28 16:02:09 +00:00
svenbarth
f1a5fbc0df * rename TIntfMethodEntry.ReturnLoc to ResultLocs for consistency with both ResultType and TVmtMethodParam.ParaLocs
git-svn-id: trunk@35347 -
2017-01-28 13:28:03 +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
03715bd9a8 + add data records TInterfaceData for COM and TInterfaceRawData for raw interfaces that allow for easier access to data that's only accessible by using pointers (and keeping track of alignment) without further polluting TTypeData
git-svn-id: trunk@35339 -
2017-01-27 16:53:47 +00:00
svenbarth
c6233697be + add utility properties to TPropData to access a specific TPropInfo or the end of the known data of all properties
git-svn-id: trunk@35338 -
2017-01-27 16:49:47 +00:00
svenbarth
bf2891938f + add utility properties to TPropInfo to easily access the next TPropInfo in a list of prop infos (TPropInfo.Next) or the direct, unpadded end of the known information (TPropInfo.Tail)
git-svn-id: trunk@35337 -
2017-01-27 16:47:45 +00:00
svenbarth
3b1ae57844 * allow for AlignTypeData() to be inlined
git-svn-id: trunk@35322 -
2017-01-20 15:39:33 +00:00
svenbarth
8e510da317 * adjust AlignTypeData to take a Pointer as argument as it also needs to be used for e.g. subrecords inside TTypeData (e.g. the property table of interfaces)
git-svn-id: trunk@35321 -
2017-01-20 15:38:51 +00:00
svenbarth
e827c28722 + not only add pfResult to the compiler, but also indeed to TParamFlag
git-svn-id: trunk@35291 -
2017-01-13 16:40:09 +00:00
svenbarth
ecb878a7a7 * move PParameterLocation before TParameterLocation for consistency with all other pointer declarations in the unit
git-svn-id: trunk@35285 -
2017-01-13 16:13:18 +00:00
svenbarth
fe28403330 + two more pointer types (PPropData for TPropData and PParameterLocations for TParameterLocations)
git-svn-id: trunk@35284 -
2017-01-13 16:12:26 +00:00
svenbarth
990b0e1657 * fix TParameterLocations.GetLocation()
git-svn-id: trunk@35283 -
2017-01-13 16:11:10 +00:00
svenbarth
0dbc123557 * ensure that TRegisterType and TSubRegister have a size of 1 by moving them at the correct location
git-svn-id: trunk@35282 -
2017-01-13 16:10:17 +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
bd8a7be17e * better implementation of TProcedureParam.GetFlags that correctly handles a TParamFlags with a size > 1 even on big endian
git-svn-id: trunk@35262 -
2017-01-08 12:41:06 +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
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
4717d78ac3 * as restructuring TTypeData to correctly layout tkBool for 64-bit Booleans is basically impossible at least add a comment for tkBool to the tkInt64 and tkQWord branches
git-svn-id: trunk@35188 -
2016-12-23 16:26:16 +00:00
svenbarth
73ed1a9bf1 * fix for Mantis #31140: applied patch by Maciej Izak; this way it's clear what purpose ManagedFldCount has in FPC compared to Delphi
Commit message of patch:

+ New field TotalFieldCount for TTypeData
* Mark ManagedFldCount as deprecated
* Adjusted test trtti12.pp

git-svn-id: trunk@35180 -
2016-12-23 15:32:44 +00:00
svenbarth
2acf542737 * extend TParamFlag by pfConstRef which is set for constref parameters
* extend test trtti9.pp accordingly

git-svn-id: trunk@35175 -
2016-12-20 21:37:07 +00:00
svenbarth
1553aa5639 * declare the first field of TProcedureParam as TParamFlags to avoid potential problems if more than 8 entries should be used (especially if some day the hidden Self and High parameters should be written)
* rename first field of TProcedureParam to ParamFlags and introduce a property Flags for backwards and Delphi compatibility

git-svn-id: trunk@35174 -
2016-12-20 21:13:04 +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
460f309035 * fix for Mantis #31123, applied patch by Maciej Izak
* adjusted test trtti10.pp due to renamed RecInitTable field

Original commit message:

Public interface for init table for records in TypInfo:

* Rename RecInitTable to RecInitInfo (because it is special kind of PTypeInfo for init table of record). Has more sense in practical usage.
+ New structure TRecInitData (and related PRecInitData) to handle data for (init) type info for records (aka init table)
+ New structure TInitManagedField and pointer type PInitManagedField (for init table)
+ Special helper property RecInitData to get PRecInitData for tkRecord

+ test attached

git-svn-id: trunk@35134 -
2016-12-16 13:43:12 +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
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
michael
0d772ae198 * Patch from Silvio Clecio to remove unused variable (bug ID 31044)
git-svn-id: trunk@35062 -
2016-12-04 11:56:05 +00:00
svenbarth
fde867cd5c * change IIDStr from a field to a property as otherwise the compiler would access the wrong field offset as it assumes RawUnitName to be a 255-byte ShortString
git-svn-id: trunk@35026 -
2016-12-01 12:59:20 +00:00
svenbarth
4fb77b71ec * fix for Mantis #31029, based on the patch provided by Silvio Clécio: PArrayOfByte is not necessary and in fact the purpose of TArrayOfByte is a different one from reference counting (namely to ensure correct passing of the parameter), so renamed accordingly (plus a comment); similar change in SetDynArrayProp. Also Get-/SetPropValue in Variants unit has been adjusted to make use of Get-/SetDynArrayProp.
+ added adjusted test

git-svn-id: trunk@35025 -
2016-11-30 19:32:41 +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
6d81760136 typinfo.pp, TTypeData:
* document the property data that follows for interface types (both COM and Corba)

git-svn-id: trunk@33106 -
2016-02-19 15:23:52 +00:00
pierre
701a610f4d Use CodePointer for all CheckVariantEvent parameter typecast
git-svn-id: trunk@32864 -
2016-01-06 14:04:31 +00:00
michael
b9da082e29 * Patch from Silvio Clecio to Extends SetPropValue/GetPropValue (bug ID 28278)
git-svn-id: trunk@32858 -
2016-01-05 20:00:41 +00:00
nickysn
e2ed8f2251 * fixed various procvars being casted to pointer instead of codepointer in the rtl
git-svn-id: trunk@32167 -
2015-10-27 17:25:27 +00:00
yury
7c62aadf65 * Fixed string conversion warnings in RTL.
git-svn-id: trunk@31752 -
2015-09-17 17:25:57 +00:00
florian
53d6f6bc55 * handle dyn. arrays and interfaces correctly in TypInfo.SetOrdProp
git-svn-id: trunk@30141 -
2015-03-08 09:40:36 +00:00
nickysn
070955bcd0 * fixed 'data element too large' error in i8086 far data memory models
git-svn-id: trunk@27390 -
2014-03-30 18:17:37 +00:00
nickysn
fec4c6a6e2 * various rtl fixes that allow objpas.integer to be 16-bit on 16-bit targets
(still not sure if it's a good idea, but trying, at least, is harmless - we
  can always rollback to integer being equal to longint)

git-svn-id: trunk@26966 -
2014-03-06 01:10:18 +00:00
nickysn
e8005f9485 * fixed compilation of unit typinfo in the i8086 medium memory model
git-svn-id: trunk@25119 -
2013-07-16 15:13:11 +00:00
nickysn
79db53b049 * TPropInfo.GetProc, .SetProc and .StoredProc changed to CodePointer for compatibility with the i8086 medium memory model
git-svn-id: trunk@25117 -
2013-07-16 14:50:16 +00:00
paul
fa0d5bb66e rtl: add tkBool into TTypeData case (issue #0024538)
git-svn-id: trunk@24794 -
2013-06-03 00:59:23 +00:00
nickysn
4bc99b1315 * use a PtrInt cast in typinfo.SetObjectProp
git-svn-id: trunk@24612 -
2013-05-25 18:47:44 +00:00
nickysn
fe48700483 * another i8086 compilation fix for typinfo
git-svn-id: trunk@24602 -
2013-05-25 15:51:36 +00:00
nickysn
4b220d7261 * fixed 'data element too large' error when compiling typinfo on i8086
git-svn-id: trunk@24600 -
2013-05-25 15:43:26 +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