[fpc-devel] Closures
Jonas Maebe
jonas.maebe at elis.ugent.be
Tue Jan 12 17:07:09 CET 2016
Blaise wrote on Wed, 09 Dec 2015:
> On 09.03.2015 16:36, Blaise at blaise.ru wrote:
> A) Things that work (at least, expected to -- before the merge):
> * accessing outer variables/parameters/Selves from such routines
> and from routines nested in them;
First of all, thanks for your work, and sorry for the late reaction.
I was wondering whether you could rework the above functionality based
on the code in ncgnstld.pas/ncgnstmm.pas. That is code which is used
by the JVM and LLVM code generators to access nested variables. It
adds all variables that are used by nested routines to a record, and
then passes a pointer to this record as "parentfp" parameter (since
those platforms do not have a stack or frame pointer register that can
be passed on). This seems quite similar to what you're doing with
load_captured_sym() etc. Alternatively, maybe your code is better and
that code could be refactored to make use of your routines. I have not
yet studied your code in detail yet.
One advantage would be that the existing code already handles this too
(for plain nested routines):
> B) Things that do not work (not planned to be addressed before the merge):
> * accessing outer local-variables/parameters/Selves that are
> located more than one level higher than the nameless routine;
Jonas
More information about the fpc-devel
mailing list