Commit Graph

534 Commits

Author SHA1 Message Date
florian
70b8789262 o basic extended pascal support:
+ automatically loaded helper unit
  * Makefiles adapted
  * mode switch
  * mode switches reorganized
+ TimeStamp support

git-svn-id: trunk@32330 -
2015-11-15 15:13:36 +00:00
Jonas Maebe
ed211b9888 * don't use symid anymore as fallback when sorting fields, as it's no longer
guaranteed to be set. Instead, temporarily assign fieldoffsets to determine
    their order in the sort function (fixes webtbs/tw15415 with -O4 after
    r32153)

git-svn-id: trunk@32159 -
2015-10-26 17:31:11 +00:00
Jonas Maebe
2cea723a0d * only write the parts of the unit localsymtables that are actually needed:
the defs and syms (recursively) referred by inline routines and by the WPO
    info
   o defs and syms are no longer added immediately to the module's deflist/
     symlist, even if they are created as "registered". Instead,
     "doregister=true" simply means "add it to the symbol table at the
     top of the symtable stack"
   o normally only when a sym/def is deref'ed, it gets added to the module
     symlist/deflist and defid/symid gets a (unique) value
   o in cases where we use(d) the defid to construct unique names within the
     current module, you now have to call call the tdef.new unique_id_str()
     method. If the def was not yet registered, we will reserve room for it
     in the deflist (to get a unique id), but the defid gets set to a
     negative value computed from its position in the deflist. Should it
     have to be written to the ppu file later on, the defid will be
     modified to the actual position in the deflist. For both values,
     new unique_id_str() will return the same result so that references
     to this def before and after actual registrations are the same (needed
     for the JVM backend, but also a good principle in general)

   Overall: don't directly use symid/defid anymore to get unique identifiers,
     but use tdef.new unique_id_str() instead (if necessary, a similar routine
     for tsym can be added)

   The result is the ppu file size gets reduced significantly after its big
   increase as a result of the high level typed constant builder (which creates
   a lot of defs). The result is even more efficient than before, as other
   unneeded defs/syms from the localsymtables don't get saved/restored anymore
   either.

git-svn-id: trunk@32153 -
2015-10-25 19:22:00 +00:00
florian
0ffe6157a8 * cast hsym with the correct type, should resolve issue #28862
git-svn-id: trunk@32125 -
2015-10-22 19:07:31 +00:00
pierre
6435968a3b Introduce tabstractsubsymtable class that uses subentryid to use it also for tenumsymtable and tarraysymtable, to fix errors for ppudump util with -VH option
git-svn-id: trunk@31798 -
2015-09-23 16:37:40 +00:00
Jonas Maebe
5a50d05e50 * fixed skipping if intermediate fields in llvm shadow symtable
git-svn-id: trunk@31640 -
2015-09-12 23:32:56 +00:00
svenbarth
6fb71e55fd symtable.pas, tparasymtable:
* checkduplicate: also ensure that the owner of the procdef is assigned before using it

git-svn-id: trunk@31589 -
2015-09-11 13:09:17 +00:00
Jonas Maebe
413680f593 * factored out getting a previously created internal type by name
git-svn-id: trunk@31247 -
2015-07-30 16:57:52 +00:00
Jonas Maebe
89c4bd8522 * index the llvm shadow symtable with a fieldvarsym rather than with the
index of the corresponding llvm fieldvar, as this index is a member
    of the fieldvarsym that only gets initialised once the llvm shadow
    symtable gets built, which in turn is triggered by trying to access
    it for the first time -> if fieldvarsym.llvmfieldnr got loaded by
    the compiler before evaluating the llvmst expression and if the
    llvmst hadn't been built yet, this llvmfieldnr was not yet initialized

git-svn-id: trunk@31060 -
2015-06-13 22:48:37 +00:00
florian
7dd1d6aa77 o fixes handling of iso i/o parameters/program parameters:
* explicit reset is needed
  * variable must be declared again

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

git-svn-id: trunk@30614 -
2015-04-16 21:25:22 +00:00
Jonas Maebe
25e6eaf07f * store the to be used recordalignmin and maxcrecordalign settings inside
(abstract)recordsymtables, so that these settings don't depend on the
    current user settings when internally creating record definitions

git-svn-id: branches/hlcgllvm@30343 -
2015-03-27 21:25:56 +00:00
Jonas Maebe
bd203a5b57 * synchronised with trunk till r30240
git-svn-id: branches/hlcgllvm@30241 -
2015-03-15 19:44:58 +00:00
Jonas Maebe
3d9713b9c8 * has_single_field() now looks recursively into fields that are aggregate
types until it finds a non-aggregate type, and then returns "true" if
    that aggregate (record or array) contains one element
  * it now also returns the type of that element directly rather than a
    tfieldvarsym, since we only care about the type and in case of an array
    there is no field

git-svn-id: trunk@30205 -
2015-03-14 18:35:53 +00:00
Jonas Maebe
67b8aceaee * synchronized with privatetrunk till r30095
git-svn-id: branches/hlcgllvm@30101 -
2015-03-05 20:32:15 +00:00
pierre
af883cdcb7 Avoid warning for function not set if noreturn modifier is used
git-svn-id: trunk@29710 -
2015-02-15 18:01:22 +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
Jonas Maebe
8fe981cccb * also give a warning when a field masks an identifier from a category
* also give a warning when a field/parameter/local variable masks an
    identifier from a class helper that's in scope

git-svn-id: trunk@29498 -
2015-01-17 15:38:29 +00:00
Jonas Maebe
990e47f2d3 * give a warning instead of an error if a parameter or local variable in a
an Objective-C method masks an identifier from a category, because due
    to the fact that all standard categories are imported at the same time via
    the CocoaAll unit, this can often happen with categories you don't know/
    care about. These errors also didn't happen in 2.6.x

git-svn-id: trunk@29497 -
2015-01-17 15:27:42 +00:00
svenbarth
5fd47d5e00 Fix for Mantis #26483. This regression was introduced by famous revision 27861 which introduced partial specializations (and thus that specializations can be part of local- and parasymtables as well).
symtable.pas, is_visible_for_object:
  * if the symtable belongs to a specialization we need to ignore any owning local- or parasymtable as well to determine which unit it belongs to

+ added test

git-svn-id: trunk@29482 -
2015-01-16 14:23:49 +00:00
florian
9a9bf4be91 * write better hint message about the first occurence of an identifuer in case of a duplicate identifier error
git-svn-id: trunk@29400 -
2015-01-04 21:23:26 +00:00
Jonas Maebe
f6f304e0ca * check for duplicate identifiers when inserting union symtables into the
parent record symtable (mantis #26704)

git-svn-id: trunk@28820 -
2014-10-14 20:30:14 +00:00
Jonas Maebe
9d9e0a578b * return the next field from tabstractrecordsymtable.findfieldbyoffset() if
there is no field at that exact offset, so we can also use it to find the
    next field in case there is alignment padding

git-svn-id: branches/hlcgllvm@28754 -
2014-10-06 20:53:22 +00:00
Jonas Maebe
5c75b6dd6b * synchronised with trunk up till r28402
git-svn-id: branches/hlcgllvm@28403 -
2014-08-13 16:04:30 +00:00
Jonas Maebe
142d5d6d06 - removed get_jumpbuf_size/align, use rec_jmp_buf instead
git-svn-id: branches/hlcgllvm@28371 -
2014-08-10 19:40:16 +00:00
Jonas Maebe
dedf7e9384 + tabstractrecordsymtable.findfieldbyoffset() method to get the (first, in
case of variant records) fieldvarsym corresponding to the given offset

git-svn-id: branches/hlcgllvm@28321 -
2014-08-06 18:04:21 +00:00
svenbarth
f1bfb398e4 Fix for Mantis #26456.
symtable.pas, searchsym_in_helper:
  * check whether extendeddef is assigned as this function is called when parsing the extended type and it was not found (the second pass is to display a more accurate error message and was added some weeks ago)

+ added test

git-svn-id: trunk@28242 -
2014-07-20 13:40:01 +00:00
Jonas Maebe
c730e16031 * changed the syntax for block procvars from "xxx is block" to
"reference to ...; cdecl;". The "reference to ..." syntax is what Delphi
    uses for anonymous function references. The "cdecl;" indicates that this
    is for the C-variant of such references, which is what blocks are

git-svn-id: branches/blocks@28233 -
2014-07-18 09:15:29 +00:00
Jonas Maebe
4ff597afae * call "message" rather than "cgmessage" when throwing fatal errors, because
cgmessage won't do anything in case cgerror is already set (and in several
    places we assume that the compiler will immediately abort after throwing a
    fatal error)

git-svn-id: trunk@28229 -
2014-07-18 09:09:21 +00:00
Jonas Maebe
bacd303208 * synchronized with trunk up to r27758
git-svn-id: branches/hlcgllvm@27779 -
2014-05-12 16:12:34 +00:00
svenbarth
c623824374 Fix for Mantis #25605.
symtable.pas, search_objectpascal_helper:
  * handle more symbol types than just properties and methods; afterall helpers can have types, static variables and constants as well

+ added test

git-svn-id: trunk@27534 -
2014-04-11 16:13:44 +00:00
Jonas Maebe
4a7e6b8b8f * instantiate the cpu-specific version of all defs/syms when loading them
from ppu (was only done for absolutevarsym until now)

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

git-svn-id: trunk@27361 -
2014-03-29 22:31:55 +00:00
Jonas Maebe
103414136d + support for tabstractlocalsymtable.iscurrentunit(). Required so that we
don't generate imports for nested routines in the llvm code generator,
    as we check whether we have to do this based on whether or not the
    procdef's owner is in the current unit (and that owner is a localsymtable
    in case of a nested routine)
   o nested calls now work with the llvm code generator

git-svn-id: branches/hlcgllvm@27139 -
2014-03-14 18:22:25 +00:00
Jonas Maebe
cefcb856b6 + code from the old llvm branch to create a "shadow symtable" for records
that contains their mapping to LLVM (mainly getting rid of variant parts
    and adding explicit padding when not using {$packrecords c})

git-svn-id: branches/hlcgllvm@26988 -
2014-03-06 21:40:43 +00:00
Jonas Maebe
5fc4af09dd * don't crash when searching for a type helper in an anonymous array (or
other non-record/objectdef-based) type (mantis #25504)

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

git-svn-id: trunk@25847 -
2013-10-25 19:44:27 +00:00
paul
ce6c8c1b59 compiler: search namespace symbols also in the interface symtable of a unit when we are registering a unit with a namespace in the implementation section (fixes issue #0025059)
git-svn-id: trunk@25560 -
2013-09-25 02:25:26 +00:00
paul
d373ad27bc compiler: don't allow unit/namespace symbols be visible outside current unit or unit of currently specialized generic
git-svn-id: trunk@25559 -
2013-09-25 00:29:56 +00:00
paul
f3963172ba compiler: don't look at unit and namespace symbols from other units while searching for a type (issue #0025054)
git-svn-id: trunk@25536 -
2013-09-23 09:22:47 +00:00
svenbarth
9d48bc0baf Implement cross unit type overloading of generics. This fixes the regression introduced with revision 25498.
symtable.pas:
  + add new tsymbol_search_flag type which can be passed to various searchsym* routines
  + add support to not call "addsymref"
  + add new searchsym_with_flags function that calls searchsym_maybe_with_symoption
  * adjust searchsym_maybe_with_symoption, searchsym_in_class & searchsym_in_helper to use new flag type instead of Boolean arguments
  * adjust searchsym & searchsym_with_symoption which call the modified functions
nutils.pas, handle_staticfield_access:
  * adjust searchsym_in_class call
pexpr.pas, handle_factor_typenode, postfixoperators, factor:
  * adjust searchsym_in_helper and searchsym_in_class calls
pinline.pas, new_function:
  * adjust searchsym_in_class call
scanner.pas, try_consume_nestedsym:
  * adjust searchsym_in_class call
fmodule.pas, tmodule:
  + add genericdummysyms field which is a TFPHashObjectList that contains TFPObjectList instances per generic dummy that in turn contains tgenericdummysyms instances
pgenutil.pas:
  + add function split_generic_name to split a generic name into non-generic name and count value of type parameters
  + add function resolve_generic_dummysym which tries to use the new genericdummysyms field to find the real symbol of a dummy sym
  * generate_specialization: adjust searchsym_in_class call
  * specialization_init/specialization_done: save/restore genericdummysyms of module
symdef.pas, tdefawaresymtablestack:
  + add new intermediate method pushcommon which is used by both push and pushafter
  + add new intermediate method remove_helpers_and_generics (which calls remove_generics and remove_helpers if necessary)
  * rename removehelpers to remove_helpers
  * rename addhelpers to add_helpers_and_generics and extend it to correctly fill current_module.genericdummysyms
  * call remove_helpers_and_generics from pop instead of remove_helpers
ptype.pas, single_type, read_named_type.expr_type, read_named_type:
  * try to resolve symbols with sp_generic_dummy with resolve_generic_dummysym

+ added test

git-svn-id: trunk@25519 -
2013-09-18 14:28:46 +00:00
svenbarth
f1f89c77c3 Finally refactor "b_needs_init_final" flag to be a symtable flag which is written to/loaded from the PPU (as discussed in the thread "Status report for "class helpers"" in fpc-devel on 29th January 2011).
symconst.pas:
    + add "sto_needs_init_final" value to "tsymtableoptions"
symtable.pas:
    - TStoredSymtable: remove "b_needs_init_final"
    + TStoredSymtable: add "init_final_check_done" (which is False by default)
    * TStoredSymtable.ppuload: set "init_final_check_done" to True if PPU is loaded (because the flag will then already be restored)
    * TStoredSymtable.needs_init_final: check the symbols only if "init_final_check_done" is not set yet
    * TStoredSymtable._needs_init_final: only check the symbol if "sto_needs_init_final" is not set yet and set the flag accordingly if needed
utils/ppuutils/ppudump.pp:
    * respect the new flag

git-svn-id: trunk@24523 -
2013-05-17 12:15:13 +00:00
florian
075abd6220 + support of stackframesize for arm thumb
+ estimatedtempsize to get a good estimatation for architectures which require to know the stack size before

git-svn-id: trunk@24188 -
2013-04-07 21:00:38 +00:00
svenbarth
70886d1727 Fix the exception reported in Mantis #24072. This does not mean though that the bug is fixed, because the bug itself is related to the topic "partial specialization".
symtable.pas, sym_is_owned_by:
	* instead of checking in which symtables to not look, specify in which tables to look (namely object- and recordsymtables)

git-svn-id: trunk@24180 -
2013-04-07 13:44:56 +00:00
Jonas Maebe
bab4aac42e * use same symtable check in sym_is_owned_by() as in is_owned_by() to
determine whether or not we should stop (local/parasymtable)

git-svn-id: trunk@23583 -
2013-02-06 21:39:43 +00:00
Jonas Maebe
a972de5a32 * renamed the first parameter of is_owned_by() from "childdef" into
"nesteddef", because it's about def's owned by other defs, not about
    parent/child relations like in OOP
  * stop checking whether a def is owned by another one when we reach a
    para/localsymtable, since a type declared locally in a record/object
    method is not nested inside the record/object type (fixes mantis
    #23819)

git-svn-id: trunk@23582 -
2013-02-06 21:39:39 +00:00
svenbarth
344571cb4e Added support for type helpers. In non Delphi modes they use "type helper" and in mode Delphi they use "record helper". They can also be used on constants.
symconst.pas:
  + extend "thelpertype" by "ht_type" which tells the code in "pdecobj.parse_extended_type" that a type helper declaration has been parsed
node.pas:
  + add a constant which identifies all constant node types
ptype.pas:
  + read_named_type: add a parameter "hadtypetoken" to tell the code whether a "type" token had been parsed before
  + read_named_type: if an identifier "helper" is parsed we need to check whether "hadtypetoken" is true and the modeswitch "m_class" is set, but the "m_delphi" one is not; in that case we have a "type helper" declaration
pgenutil.pas, generate_specialization:
  * adjust call to read_named_type
pdecl.pas, types_dec:
  * adjust call to read_named_type

pdecobj.pas:
  * parse_extended_type: extend for correct handling of primitive types (includes Delphi compatible handling as well) and reject types that are explicitly not allowed
  * method_dec: require "static" for class methods in type helpers
  * method_doc: allow constructors for type helpers as well
paramgr.pas, tparamanager:
  * set_common_funcretloc_info: handle type helper constructors like record constructors
  * handle_common_ret_in_param: the "self" value of a type helper constructor is also returned in a parameter
pexpr.pas:
  + add a function to postfixoperators which tries to find and apply a type helper for a given type
  * postfixoperators: try to apply type helpers for ordinal constants
  * postfixoperators: use the correct string type for string constants
  * postfixoperators: try to apply type helpers for enum constants
  * postfixoperators: try to apply type helpers for arrays
  * postfixoperators: try to apply type helpers for Variant
  * postfixoperators: try to apply type helpers for pointer types
  * postfixoperators: try to apply type helpers for other types
  * factor: check postfixoperators after _REALNUMBER, _CCHAR, _CWCHAR, _TRUE and _FALSE
  * factor: also check postfixoperators if a _POINT follows a _NIL

symdef.pas, tdefawaresymtablestack.addhelpers:
  * use "generate_objectpascal_helper_key" to generate the key
symtable.pas:
  + add function to generate the key value for the map of extended types using the extended def
  * adjust "search_last_objectpascal_helper" and "search_objectpascal_helper" to handle primitive types as well
  * use the new "generate_objectpascal_helper_key" function to generate the key

pparautl.pas:
  * insert_self_and_vmt_para: don't insert the $vmt symbol for record or type helpers (ToDo: check whether class helpers really need the symbol as well)
  * insert_self_and_vmt_para: pass "self" as var parameter for type helpers as well
psub.pas, generate_bodyentry_block: 
  * also allow type helpers for constructor methods
ncal.pas, tcallnode.gen_self_tree:
  * also use a temp variable for type helper constructors
ncgcal.pas, tcgcallnode.secondcallparan:
  * allow Pointers to be passed as address param if it is the Self value of a type helper extending a pointer type
  * correctly handle the location in case of type helper constructors

+ add tests

git-svn-id: trunk@23580 -
2013-02-06 09:49:35 +00:00