Skip to content

Commit 6f8320c

Browse files
committed
piccode: Reset the context on each compile
1 parent df60bdd commit 6f8320c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/main/java/org/piccode/backend/Compiler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public static void prepareGlobalScope(String file, String globalScopeName) {
190190
scope_id.column = 0;
191191
scope_id.line = 1;
192192
scope_id.file = file;
193+
Context.top.resetContext();
193194
Context.top.pushStackFrame(scope_id);
194195
Context.top.putLocal("true", new PiccodeBoolean("true"));
195196
Context.top.putLocal("false", new PiccodeBoolean("false"));

src/main/java/org/piccode/rt/Context.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ public Context() {
4343
call_frames = new Stack<>();
4444
}
4545

46+
public void resetContext() {
47+
annotations.clear();
48+
modules.clear();
49+
threadContexts.clear();
50+
futureMap.clear();
51+
objectPool.clear();
52+
call_frames.clear();
53+
}
54+
4655
public static int makeThreadContext(Context base) {
4756
int index = threadContexts.size();
4857
var context = new Context();

0 commit comments

Comments
 (0)