Commit Graph

100 Commits

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