Commit Graph

65286 Commits

Author SHA1 Message Date
Sven/Sarah Barth
943da88dda * rework tprocsym.Find_procdef_byprocvardef so that its implementation can be used in a more generic manner 2022-05-26 21:44:24 +02:00
Sven/Sarah Barth
f2305d1cee * if an invokable that isn't a function reference is followed by a point in a mode that doesn't use TP/Delphi style calling without parameters then don't call it like is done with normal procvars 2022-05-26 21:44:23 +02:00
Sven/Sarah Barth
76df7144ba * implement necessary conversion functionality for anonymous procdefs to function reference interfaces including capturing of variables 2022-05-26 21:44:23 +02:00
Sven/Sarah Barth
f8b1801a8f + implement necessary functionality in tcgprocinfo to initialize and populate the capturer
Based on code by Blaise.ru
2022-05-26 21:44:23 +02:00
Sven/Sarah Barth
9b9ae2db1a * two function references are equal to each other as long as their signatures match 2022-05-26 21:44:23 +02:00
Sven/Sarah Barth
6fe9a15094 + add function to check whether a procdef can be converted to a function reference 2022-05-26 21:44:22 +02:00
Sven/Sarah Barth
749faa42ee * do not insert the $result symbol again when the VMT for the capturer is built 2022-05-26 21:44:22 +02:00
Sven/Sarah Barth
9aac622dc9 + add necessary core functions and functionality to implement capturing of variables
Based on code by Blaise.ru
2022-05-26 21:44:22 +02:00
Sven/Sarah Barth
0e0739a64f * regenerate msg{idx,txt}.inc 2022-05-26 21:44:22 +02:00
Sven/Sarah Barth
a0171e4335 + add an error message for when a symbol can't be captured 2022-05-26 21:43:41 +02:00
Sven/Sarah Barth
897f0e1784 * if a symbol is not part of a symtable then assume it's from the current module 2022-05-26 21:43:40 +02:00
Sven/Sarah Barth
b5ab81c983 * an internal definition in a specialization might not have a genericdef 2022-05-26 21:43:40 +02:00
Sven/Sarah Barth
90ebeb275a + add utility function to retrieve a file position of a usage of a type symbol from a type's definition 2022-05-26 21:43:40 +02:00
Sven/Sarah Barth
3eac88eeaf * protected symbols are visible for defs declared in a local symtable as well 2022-05-26 21:43:40 +02:00
Sven/Sarah Barth
533a11ec80 * correctly handle calling convention for function references 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
47d7520b32 * consider invokables as related when they're equal 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
145b37425d + add function funcref_equal to check whether two function references are considered equal enough to be assignable 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
ff0b560fe4 * set the flag that the symtable contains a generic at the end of the corresponding block of types_dec() to ensure that the owner is assigned correctly 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
6299e94c8f * set the type symbol of the procvar while it is parsed so that a function reference can have itself as part of the parameters or the return type 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
06a00b53c3 * also handle function references when a generic one had been parsed 2022-05-26 21:43:39 +02:00
Sven/Sarah Barth
b297199ab6 + add a field to denote that a symbol (mainly local and parameter ones) was captured through another symbol 2022-05-26 21:43:38 +02:00
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