Commit Graph

133 Commits

Author SHA1 Message Date
florian
ff295bf349 * delay setting of pd_body and pd_implement till the header of a generic
procedure is parsed, resolves #37261

git-svn-id: trunk@45717 -
2020-06-30 20:36:51 +00:00
florian
e7f7927ca9 + initialize variables, so compilation with -O3 works
git-svn-id: trunk@45141 -
2020-04-27 19:19:54 +00:00
svenbarth
04554d7505 * use a more detailed error message if a type is not allowed for a generic constant parameter
git-svn-id: trunk@45092 -
2020-04-26 11:46:24 +00:00
svenbarth
a467332187 * fix for Mantis #36975: arraydefs are not allowed for generic types (this is only used for type declarations; for specializing constant strings which are char arrays are still allowed)
+ added test

git-svn-id: trunk@45089 -
2020-04-26 11:46:10 +00:00
svenbarth
60345366f2 * fix for Mantis #35140: apply patch by Ryan Joseph together with some further changes by me to add support for constant parameters in generics
+ added tests

git-svn-id: trunk@45080 -
2020-04-25 22:12:35 +00:00
svenbarth
41a6957f7d * keep track of the fileposinfo for generic constraints
git-svn-id: trunk@44188 -
2020-02-16 09:53:32 +00:00
florian
b7afb2431c * do not allow constraints in headers of procedure implementations in delphi mode, resolves #36584
* better error message if a constraint is found at a wrong location

git-svn-id: trunk@44174 -
2020-02-14 20:56:55 +00:00
svenbarth
c6a4d10f61 * for deciding whether to swap a generic's buffer use the module's flag instead of the def's
git-svn-id: trunk@44073 -
2020-01-30 21:49:07 +00:00
pierre
d1e4066477 Hopefully fix problems related to loading of ppufile generated with other endianess for generics
git-svn-id: trunk@44056 -
2020-01-28 23:43:56 +00:00
yury
1b3a3a7983 * Removed lot of unused local vars. It is useful to turn on the notes in options. :)
git-svn-id: trunk@44053 -
2020-01-28 18:45:33 +00:00
svenbarth
3e7dc25667 * fix for Mantis #36496: correctly handle the function result alias variable inside generic functions
+ added tests

git-svn-id: trunk@43823 -
2019-12-30 21:35:26 +00:00
svenbarth
bf5d75e594 * move the common sequence to build a VMT for an objectdef into a separate procedure (based on a patch by Blaise.ru)
git-svn-id: trunk@43674 -
2019-12-11 22:42:53 +00:00
svenbarth
97eefb6ac3 - the error recovery handling is no longer required
git-svn-id: trunk@43588 -
2019-11-25 20:28:29 +00:00
svenbarth
5b71ba2a9b * treat a missing genericdef with no symname set as an internal error
git-svn-id: trunk@43587 -
2019-11-25 20:28:26 +00:00
svenbarth
ef6c9e930b * correctly handle the genericdef being a procdef, otherwise no code will be generated (and no error either :/ )
+ added test

git-svn-id: trunk@43586 -
2019-11-25 20:28:23 +00:00
svenbarth
1abc9c1fe7 * when specializing a routine all nested specializations must go to the para- or localsymtable as otherwise the symbol can't be found to be registered
git-svn-id: trunk@43568 -
2019-11-24 00:04:31 +00:00
svenbarth
d79e2ee9da * also store, reset and restore the current module's procinfo
git-svn-id: trunk@43566 -
2019-11-24 00:04:23 +00:00
Jonas Maebe
a051b8d225 - remmoved doregister parameter from t*sym constructors, as the registration
is handled automatically nowadays

git-svn-id: trunk@42998 -
2019-09-14 17:30:45 +00:00
Jonas Maebe
d8903ce6b3 - removed maxcrecordalign parameter/field from recordsymtables, as this value
cannot be modified in the settings (so we can directly use the one from
    current_settings)

git-svn-id: trunk@42447 -
2019-07-14 19:24:32 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
Jonas Maebe
e008785152 * insert the hidden parameters for objectdef methods after resolving
overrides but before generating the VMT, so that these hidden parameters
    are part of the procdefs stored in the VMT (fixes some LLVM type errors
    after r41716)

git-svn-id: trunk@41884 -
2019-04-16 16:11:50 +00:00
Jonas Maebe
ed2ae508d0 * only add hidden parameters for objectdef methods after generating the vmt,
so that they take into account inherited calling conventions (mantis #35233)
   o don't needlessly calculate the paraloc info when generating a JVM mangled
     name

git-svn-id: trunk@41716 -
2019-03-16 19:14:14 +00:00
Jonas Maebe
91d5457b38 * moved around/replaced the following procedures to stop nflw from depending
on pdecsub (node units should not depend on parser units):
   o maybe_add_public_default_java_constructor()
   o handle_calling_convention()
   o create_finalizer_procdef() (replaced with create_outline_procdef())
   o insert_record_hidden_paras()
   o handle_calling_convention()
   o proc_add_definition()
   o build_parentfpstruct()
   o maybe_guarantee_record_typesym()
   o get_first_proc_str()
  * factored out the creation of a procinfo for a nested procdef based on a
    subnodetree of the current procdef into tprocinfo.create_for_outlining()

git-svn-id: trunk@40773 -
2019-01-05 16:26:33 +00:00
Jonas Maebe
28df55fe08 * moved handle_calling_convention() to pparautl
git-svn-id: trunk@40772 -
2019-01-05 16:26:29 +00:00
svenbarth
598ac21791 * if the generic dummy symbol is a procsym (with procdefs added) then this is the symbol that should be resolved to
git-svn-id: trunk@39232 -
2018-06-15 13:49:21 +00:00
svenbarth
06d7e26df0 * move code to add a symbol to the current module's generic dummy symbols into a new function pgenutil.add_generic_dummysym()
git-svn-id: trunk@36466 -
2017-06-09 14:30:23 +00:00
florian
b1dff29cbf * removed unused units
git-svn-id: trunk@36165 -
2017-05-09 19:53:14 +00:00
svenbarth
8024fcd7ec * if an operator overload in a structured type is invalid print an error only for the declaration and not the implementation as well
This fixes Mantis #31634 as far as I see it useful to; anything further would probably require extension of the message generation system by a context or such so that the compiler could write "Error in TFoo<Integer>: ..." instead of merely "Error: ..." or something like that.
No test added due to the nature of the bug.

git-svn-id: trunk@35748 -
2017-04-07 13:24:58 +00:00
maciej-izak
e4565378db * Allow for "record constraint" in Delphi mode more types like: ordinal, float, classical objects, enumerations (instead of just record). Delphi compatibility. Fix for mantis #24073.
git-svn-id: trunk@35739 -
2017-04-05 13:12:30 +00:00
svenbarth
d34acf3bc7 * fix for Mantis #31120: check current_genericdef only if the current_procinfo isn't used
+ added test

Note: the test is added to webtbs although it's right now still failing, cause I'll remove the restriction for nested procedures since the compiler now supports them correctly. Due to the way we handle generics we don't have problems with them unlike Delphi.

git-svn-id: trunk@35147 -
2016-12-17 21:20:44 +00:00
svenbarth
6ba85c2a70 * second fix for Mantis #30626: also search in parent classes for a suitable pre-existing specialization
+ added test

git-svn-id: trunk@35014 -
2016-11-29 17:04:07 +00:00
svenbarth
0a1e080089 * only create a new procsym for a specialization if it's indeed needed
git-svn-id: trunk@35013 -
2016-11-29 14:13:06 +00:00
svenbarth
a535d54bcb * fix for Mantis #30939: Rework generation of the generic name to be less relying on the type hierarchy as a specialization inside the parameter declaration would want to have the full name of the procdef including its parameters, but those are still parsed at that stage (the pretty name is still a topic onto itself however...)
+ added tests (original test was only mode fpc, test for mode delphi is added as well)

git-svn-id: trunk@35010 -
2016-11-28 18:16:49 +00:00
svenbarth
ee466b9a28 * extend tdef.fullownerhierarchyname() with a parameter that skips the inclusion of a procdef's parameter declaration using the new pno_noparams option
git-svn-id: trunk@35009 -
2016-11-28 18:06:35 +00:00
svenbarth
63b0024e4c * fix for Mantis #30626: unset current_procinfo so that further specializations don't use a symtable to specialize themselves in that they shouldn't use (cause current_procinfo takes precedence)
git-svn-id: trunk@34916 -
2016-11-18 16:17:09 +00:00
svenbarth
fd7daf91df + new overload for generate_specialization_phase1() which allows to pass a specific symbol name without the need to specify a file position
git-svn-id: trunk@34529 -
2016-09-16 15:10:51 +00:00
svenbarth
627e30f47f * factor() might return a typenode with a errordef, so check for that and don't add the typesymbol to the parameter list in that case; fixes the access violation of tw17181.pp
git-svn-id: trunk@34472 -
2016-09-09 13:04:41 +00:00
svenbarth
80c2e3b51a * special detection of an ongoing specialization for the case that a function that belongs to a generic and has said generic as parameter or result is in turn specialized as a parameter or result of another generic function
git-svn-id: trunk@34412 -
2016-09-02 15:52:03 +00:00
svenbarth
6a14bb5014 * check the owner of current_specializedef as that is Nil if a generic routine is specialized and this is the specialization of one of its parameters or its result type
git-svn-id: trunk@34411 -
2016-09-02 15:48:30 +00:00
pierre
22a7ce8972 Fix memory leak due to double srsym allocation
git-svn-id: trunk@34364 -
2016-08-21 22:26:59 +00:00
Jonas Maebe
95f28e5e0c * avoid a crash when processing synthetic methods of specialised classes:
these are generated after the other specialisation methods (via
    add_synthetic_method_implementations, rather than via
    generate_specialization_procs)
   o fixes crash in tests/test/jvm/tw20212.pp

git-svn-id: trunk@34036 -
2016-06-30 15:33:54 +00:00
svenbarth
6c3dd6b601 Another system, another regression... (this time tests/test/tgenfunc15.pp on i386-win32)
pgenutil.pas:
  * generate_specialization_phase2 & generate_specialization_procs: don't add pending specializations if we're currently parsing a generic

git-svn-id: trunk@33885 -
2016-06-03 12:36:27 +00:00
svenbarth
fd98ec56e9 Fix (hopefully last) regression introduced due to the reworking specialization of routine bodies.
pgenutil.pas:
  * process_abstractrecorddef & generate_specialization_procs: also check for a forward def is the other module is still compiling (thus an access to tprocdef.forwarddef should still be possible); this might happen due to circular references like in tests/test/tgeneric91.pp

git-svn-id: trunk@33872 -
2016-06-01 19:03:54 +00:00
florian
04a68d9b94 * fix compilation with -Oodfa
git-svn-id: trunk@33865 -
2016-05-31 21:14:53 +00:00
svenbarth
1bd43d9e37 Fix regressions.
pgenutil.pas:
  + new function maybe_add_pending_specialization() to add a pending specialization if it belongs to the current unit
  * generate_specialization_phase2: don't set up the owner as this leads to problems when using overloaded generic routines and don't add it to the pending list if it's a procdef
ncal.pas, tcallnode:
  * pass_typecheck: if we have a specialization then add it to the pending specializations once we know that we use it

git-svn-id: trunk@33843 -
2016-05-28 22:12:45 +00:00
svenbarth
1d7c19aaf0 Fix regressions.
pgenutil.pas:
  * process_procdef & process_abstractrecorddef: only check whether the procdef's generic is still a forward declaration if it's in the current unit (otherwise we would trigger an internal error)

git-svn-id: trunk@33828 -
2016-05-27 16:29:22 +00:00
svenbarth
f27ce0b159 Rework the way the method bodies for specializations are generated: instead of walking the global and local symboltable all pending specializations are kept in a list of the current module which is (for now) walked at the end of a unit/program to generate the method bodies as before.
fmodule.pas, tmodule:
  + new list pendingspecializations which keeps track of all pending specializations of the current module
psub.pas:
  * move generate_specialization_procs and related routines to pgenutil
  + new procedure read_proc_body to read a routine's body, cause generate_specialization_procs needs it (unlike the already existing overload in the implementation section, this one can only handle bodies of non-nested routines) 
pgenutil.pas:
  * generate_specialization_phase2: add the newly specialized generic to the current module's pending specializations
  * generate_specialization_procs: reworked so that it uses the new pendingspecializations field instead of walking the global and local symboltable of the current unit
pmodules.pas:
  + add pgenutil to uses due to the moved generate_specialization_procs

+ added test

git-svn-id: trunk@33826 -
2016-05-26 18:56:16 +00:00
svenbarth
2f6a1c01ba pgenutil.pas, generate_specialization_phase2:
* ensure that the owner of the newly greated def is set to the symtable we specialize in (happens with generic routines)

git-svn-id: trunk@33825 -
2016-05-26 18:37:37 +00:00
svenbarth
f8def6dbc9 Store and use procedure directives of generic routines.
scanner.pas, tscannerfile:
  + new method is_recording_tokens to check whether token recording is already active
pdecsub.pas, parse_proc_directives:
  * record tokens into the declaration token buffer of a generic routine if necessary
pgenutil.pas, generate_specialization_phase2:
  * process the procedure directives that had been recorded with the generic routine

git-svn-id: trunk@33824 -
2016-05-26 18:35:08 +00:00
svenbarth
d07b49270f Fix for Mantis #30030.
pgenutil.pas:
  * parse_generic_specialization_types_internal: ignore the parasymtable of procvars (as before the addition of generic routines) and instead use the type's hierarchy name
  * generate_specialization_phase2: specialize types of procvars into the parameter symtable as they don't have a local one

+ added test

git-svn-id: trunk@33544 -
2016-04-22 13:07:48 +00:00