Skip to content

Commit 89fecdf

Browse files
committed
piccode: Fixed a bunch of low hanging bugs
1 parent 61a96f7 commit 89fecdf

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static PiccodeValue compile(String file, String code, List<PiccodeValue>
4646
scope_id.line = 1;
4747
scope_id.file = file;
4848

49-
Compiler.prepareGlobalScope(scope_id);
49+
prepareGlobalScope(scope_id);
5050
addGlobalFunctions();
5151

5252
PiccodeValue res = new PiccodeUnit();
@@ -61,6 +61,8 @@ public static PiccodeValue compile(String file, String code, List<PiccodeValue>
6161
if (has_main) {
6262
return new CallAst(new IdentifierAst("main"), List.of()).execute();
6363
}
64+
65+
Context.top.dropStackFrame();
6466
return res;
6567
} catch (PiccodeException e) {
6668
e.reportError();
@@ -102,8 +104,8 @@ private static String sanitizeSourceFile(String code) {
102104

103105
public static void prepareGlobalScope(Ast parent) {
104106
Context.top.pushStackFrame(parent);
105-
Context.top.putLocal("true", new PiccodeBoolean("true"));
106-
Context.top.putLocal("false", new PiccodeBoolean("false"));
107+
Context.top.addGlobal("true", new PiccodeBoolean("true"));
108+
Context.top.putLocal("false", new PiccodeBoolean("false"));
107109
addGlobalFunctions();
108110
}
109111

src/main/java/org/piccode/piccodescript/Piccode.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ private static void repl(List<PiccodeValue> user_args) {
248248

249249
var bands = Chalk.on("| ").yellow();
250250
System.out.println(bands + fmt);
251-
Compiler.prepareGlobalScope(new IdentifierAst("globalScope"));
252251
// Create a terminal
253252
try (Terminal terminal = TerminalBuilder.builder()
254253
.system(true)

0 commit comments

Comments
 (0)