Skip to content

Commit f979f2a

Browse files
committed
FunctionAst: Now functions are store on the local table.
1 parent d7fa421 commit f979f2a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/org/piccode/ast/FunctionAst.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ private String formatArgs() {
5353

5454
@Override
5555
public PiccodeValue execute(Integer frame) {
56+
var ctx = frame == null
57+
? Context.top
58+
: Context.getContextAt(frame);
59+
5660
Map<String, PiccodeValue> newArgs = new HashMap<>();
5761
var cl = new PiccodeClosure(arg, newArgs, 0, body);
5862
cl.creator = this;
@@ -62,7 +66,7 @@ public PiccodeValue execute(Integer frame) {
6266
cl.file = file;
6367
cl.column = column;
6468
cl.line = line;
65-
Context.addGlobal(name, cl);
69+
ctx.putLocal(name, cl);
6670
return cl;
6771
}
6872

0 commit comments

Comments
 (0)