Skip to content

Commit dff956a

Browse files
committed
backend: Fixed the api a little bit
1 parent 1fcd9ad commit dff956a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,18 @@ public static PiccodeValue compile(String file, String code, List<PiccodeValue>
4343
try {
4444
var result = program(file, code);
4545
prepareGlobalScope(file);
46-
addGlobalFunctions();
4746

4847
PiccodeValue res = new PiccodeUnit();
4948
var has_main = false;
5049
for (var stmt : result.nodes) {
5150
if (stmt instanceof FunctionAst func && func.name.equals("main") && (func.arg == null || func.arg.isEmpty())) {
5251
has_main = true;
5352
}
54-
res = stmt.execute();
53+
res = stmt.execute(null);
5554
}
5655

5756
if (has_main) {
58-
var _result = new CallAst(new IdentifierAst("main"), List.of()).execute();
57+
var _result = new CallAst(new IdentifierAst("main"), List.of()).execute(null);
5958
Context.top.dropStackFrame();
6059
return _result;
6160
}
@@ -118,11 +117,11 @@ public static void prepareGlobalScope(String file, String globalScopeName) {
118117
Context.top.pushStackFrame(scope_id);
119118
Context.top.putLocal("true", new PiccodeBoolean("true"));
120119
Context.top.putLocal("false", new PiccodeBoolean("false"));
121-
addGlobalFunctions();
120+
addSystemFunctions();
122121
}
123122

124123

125-
private static void addGlobalFunctions() {
124+
private static void addSystemFunctions() {
126125
PiccodeIOModule.addFunctions();
127126
PiccodeArrayModule.addFunctions();
128127
PiccodeStringModule.addFunctions();

0 commit comments

Comments
 (0)