Commit Graph

65465 Commits

Author SHA1 Message Date
Sven/Sarah Barth
ec96d4242a * check hierarchy of the current generic or specialization def independant of whether it's a record- or objectdef 2022-05-26 21:43:38 +02:00
Sven/Sarah Barth
f02fc4fe0f * move checking for a def in the hierarchy to a separate nested function and use it to check the hierarchy of the current def being specialized as well 2022-05-26 21:43:38 +02:00
Sven/Sarah Barth
5cf15be434 + add a constructor for trecorddef to declare an internal record type as part of a specific other type
Based on code by Blaise.ru
2022-05-26 21:43:37 +02:00
Sven/Sarah Barth
92082ab28f * correctly handle directives for anonymous functions 2022-05-26 21:43:37 +02:00
Sven/Sarah Barth
e8b0fc88e3 * correctly handle directives for function references 2022-05-26 21:43:37 +02:00
Sven/Sarah Barth
fd26453d5a * name of result variable of anonymous functions can be changed (and must be in modes without modeswitch Result) 2022-05-26 21:43:37 +02:00
Sven/Sarah Barth
7de854ef1e + add method register_implemented_interface to tobjectdef which registers an implemented interface and - if desired - also initializes the GUID related fields of the objectdef
* use that method in all locations outside symdef that add add an implemented interface

Based on work by Blaise.ru
2022-05-26 21:43:37 +02:00
Sven/Sarah Barth
76d3a9c4b5 * generate a better name if the procdef is an anonymous one 2022-05-26 21:43:36 +02:00
Sven/Sarah Barth
cdf676c9b5 * a function also captures other nested functions when these are called 2022-05-26 21:43:36 +02:00
Sven/Sarah Barth
eaeb614887 + provide a tsym based variant of ChangeOwnerAndName 2022-05-26 21:43:36 +02:00
Sven/Sarah Barth
a7a0f47d98 * extract a symbol or def from its previous owner if that owner has OwnsObjects set to true 2022-05-26 21:43:36 +02:00
Sven/Sarah Barth
088c746d45 * reset written source lines once a section is encountered 2022-05-26 21:43:35 +02:00
Sven/Sarah Barth
6ac50f4100 + add method ResetSourceLines to TExternalAssembler to reset already written lines 2022-05-26 21:43:35 +02:00
Sven/Sarah Barth
1d4c28fb35 * regenerate msg{idx,txt}.inc after message change in last commit 2022-05-26 21:43:35 +02:00
Sven/Sarah Barth
2be8f01efe * implement assignment of anonymous functions to procedure or method variables if they either capture nothing or (in case of method variables) at most the Self variable 2022-05-26 21:43:01 +02:00
Sven/Sarah Barth
17514ed5c0 * allow to ignore Self parameters; for this the parameter skipping needs to be repeated to correctly catch all cases 2022-05-26 21:43:01 +02:00
Sven/Sarah Barth
8e2478e632 * check whether an anonymous function can be assigned to a global, method or nested function variable 2022-05-26 21:43:01 +02:00
Sven/Sarah Barth
5129c2cb9a * consider Self parameters of nested functions as captured as well 2022-05-26 21:43:01 +02:00
Sven/Sarah Barth
d56a90e5ed * keep track of symbols that are accessed from a nested/anonymous function that belong to a surrounding scope 2022-05-26 21:43:01 +02:00
Sven/Sarah Barth
ddba001b65 * ensure that nested functions of main program, main program finalization and unit initialization/finalization are generated 2022-05-26 21:43:00 +02:00
Sven/Sarah Barth
4dbdb4f0f1 + initial support for anonymous functions, for now as essentially nested functions
Based on work by Blaise.ru
2022-05-26 21:43:00 +02:00
Sven/Sarah Barth
4e4d268963 + add modeswitch for anonymous functions 2022-05-26 21:43:00 +02:00
Sven/Sarah Barth
2cc621618a * Delphi-mode calling without parenthesis 2022-05-26 21:43:00 +02:00
Sven/Sarah Barth
c3736810ac * if an interface is declared inherit the invokable flag from the parent interface 2022-05-26 21:42:59 +02:00
Sven/Sarah Barth
2ed2c21313 + add support for parsing function references 2022-05-26 21:42:59 +02:00
Sven/Sarah Barth
7f3a5eb9ab * extend tabstractprocdef.getcopyas by a parameter to control whether the copy should be registered or not 2022-05-26 21:42:59 +02:00
Sven/Sarah Barth
90eabdd6b4 * ensure insert_self_and_vmt_para can deal with a preexisting self symbol as long as it has the expected type 2022-05-26 21:42:58 +02:00
Sven/Sarah Barth
39f5534969 * adjust handle_calling_convention so that it can be used with both proc(var)defs and invokables 2022-05-26 21:42:58 +02:00
Sven/Sarah Barth
c92e290d67 * extend parse_proctype_directives to handle proc(var)defs as well as invokables 2022-05-26 21:42:58 +02:00
Sven/Sarah Barth
bb637fa389 * adjust parse_proctype_directives so that it can handle a function reference as well 2022-05-26 21:42:58 +02:00
Sven/Sarah Barth
a20bfc0753 + add utility function to check whether an invokable can be invoked without explicit parameters 2022-05-26 21:42:57 +02:00
Sven/Sarah Barth
22bbcf4b27 + add utility function to retrieve the invoke procdef of a function reference interface 2022-05-26 21:42:57 +02:00
Sven/Sarah Barth
833a971877 + add utility function to check whether an objectdef is an invokable one 2022-05-26 21:42:57 +02:00
Sven/Sarah Barth
f0748ad59b + add flag to denote that an objectdef is invokable, thus can be used like a function variable 2022-05-26 21:42:57 +02:00
Sven/Sarah Barth
122c6c92cb + add function to check whether a def is an invokable function reference 2022-05-26 21:42:57 +02:00
Sven/Sarah Barth
b28495a423 + add flag to denote an object def as a function reference 2022-05-26 21:42:56 +02:00
Sven/Sarah Barth
ec02d0abb0 + add constants for the Invoke symbol of a function reference interface (both for declaring and finding it) 2022-05-26 21:42:56 +02:00
Sven/Sarah Barth
2912e38e91 + add modeswitch for anonymous function and function references 2022-05-26 21:42:56 +02:00
Sven/Sarah Barth
5e148c1dca + add a new tproccopytyp pc_normal_no_paras to copy an abstractprocdef without its parameters (useful if the parameters themselves will be reused and the original def otherwise deleted) 2022-05-26 21:42:56 +02:00
Sven/Sarah Barth
6a9b4a1b13 + apply patch by Blaise.ru: allow initialisation of method pointers with class methods (when class types are
known at compile time)
* adjust error message when a method pointer isn't suitable
+ add tests
2022-05-26 21:42:55 +02:00
Sven/Sarah Barth
bc4eb00a7a * apply patch by Blaise.ru: proper code generation for assigning class non-static methods, accessed via a class reference type, to method pointers
+ added test
2022-05-26 21:42:55 +02:00
Sven/Sarah Barth
6e7a82440e * apply patch by Blaise.ru: avoid internal error when assigning class methods, accessed via a class reference type, to incompatible procvars
+ added tests
2022-05-26 21:42:55 +02:00
Sven/Sarah Barth
a8cf67d73b * apply patch by Blaise.ru: reject assignments of instance methods, accessed via a type, to method pointers
+ add tests
2022-05-26 21:42:54 +02:00
Sven/Sarah Barth
acee4eb27a - apply patch by Blaise.ru: pdflags are no longer required in generate_specialization_phase2() after parse_proc_directives() was done, so remove its unused modification after that call 2022-05-26 21:42:54 +02:00
Sven/Sarah Barth
e5df46722e * apply part of patch by Blaise.ru: reduce code duplication when parsing anonymous procvar types 2022-05-26 21:42:54 +02:00
Sven/Sarah Barth
bd226c00f1 * apply part of patch by Blaise.ru: check only once whether writable consts are enabled or not by determining the type of the assembly list earlier (it's only not needed in an error case anyway) 2022-05-26 21:42:54 +02:00
Sven/Sarah Barth
e5ac99a4c9 * apply patch by Blaise.ru: parse_object_proc_directives() and parse_object_record_directives() should only be called with procdefs, so change the parameter from tabstractprocdef to tprocdef to make this explicit 2022-05-26 21:42:54 +02:00
Sven/Sarah Barth
9c9c6cc81b * apply patch by Blaise.ru:
- all call sites of parse_var_proc_directives() have the tprocvardef easily available, so use parse_proctype_directives() directly
  - remove the now no longer required parse_var_proc_directives()
2022-05-26 21:42:53 +02:00
Sven/Sarah Barth
0bbfad1add * apply patch by Blaise.ru:
- avoid creation of a dummy typesym just to call parse_var_proc_directives() by introducing a new parse_proctype_directives() that takes a tprocvardef instead of a symbol like the former does
  - have parse_var_proc_directives() call parse_proctype_directives() to avoid duplicated code
2022-05-26 21:42:53 +02:00
Sven/Sarah Barth
542c3f0c4c * use tproc_parse_flags in parse_proc_dec_finish as well 2022-05-26 21:42:53 +02:00