diff options
Diffstat (limited to 'closures/compiler/nld.pas')
| -rw-r--r-- | closures/compiler/nld.pas | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/closures/compiler/nld.pas b/closures/compiler/nld.pas index 2f2dc872af..fa31b825ed 100644 --- a/closures/compiler/nld.pas +++ b/closures/compiler/nld.pas @@ -44,7 +44,10 @@ interface Be really carefull when using this flag! } loadnf_isinternal_ignoreconst, - loadnf_only_uninitialized_hint + loadnf_only_uninitialized_hint, + // the node loads a captured formal parameter from its original location; + // such node is marked so, so it will not get rewritten during the first pass + loadnf_captured_param ); tloadnode = class(tunarynode) @@ -167,7 +170,7 @@ implementation cutils,verbose,globtype,globals,systems, symnot,symtable, defutil,defcmp, - htypechk,pass_1,procinfo,paramgr, + htypechk,pass_1,procinfo,paramgr,pnameless, cpuinfo, ncon,ninl,ncnv,nmem,ncal,nutils,nbas, cgobj,cgbase @@ -393,6 +396,17 @@ implementation localvarsym, paravarsym : begin + if symtableentry.typ in [localvarsym,paravarsym] then + begin + // if the variable has been captured after the creation of this node, + // then this node is no longer relevant, + // and we shall load the variable's new location instead + // the exception is the case when we access the original location + // in order to copy the value into the capturer + if tabstractnormalvarsym(symtableentry).is_captured + and not (loadnf_captured_param in loadnodeflags) then + exit( load_captured_variable(current_procinfo.procdef, tabstractnormalvarsym(symtableentry)) ); + end; if assigned(left) then firstpass(left); if not is_addr_param_load and |
