From df6c3247c40b05266894d45136dc64f96b0cbac9 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Tue, 22 Feb 2022 11:05:30 +0000 Subject: Implement lexical scope instead of dynamic scope rules. --- functions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'functions.c') diff --git a/functions.c b/functions.c index 46cbe7a..7e462c3 100644 --- a/functions.c +++ b/functions.c @@ -141,7 +141,7 @@ runfunc(Function f, Array *left, Array *right) code = f.operator.dop; } - pushdfnframe(code, lefto, righto, left, right); + pushdfnframe(code, f.scope, lefto, righto, left, right); Datum *dfnres = evalline(code, nil, 0); popdfnframe(); @@ -228,6 +228,7 @@ rundfn(Rune *code, Datum *lefto, Datum *righto, Array *left, Array *right) Function dfn; dfn.type = FunctypeDfn; dfn.dfn = code; + dfn.scope = getcurrentdfn(); return runfunc(dfn, left, right); }else if(lefto != nil){ Function dop; @@ -237,6 +238,7 @@ rundfn(Rune *code, Datum *lefto, Datum *righto, Array *left, Array *right) dop.operator.right = righto; dop.operator.dyadic = righto != nil; dop.operator.dop = code; + dop.scope = getcurrentdfn(); return runfunc(dop, left, right); }else{ throwerror(L"Malformed call to rundfn", ENotImplemented); -- cgit v1.2.3