修复
This commit is contained in:
parent
cb1780327c
commit
e14856bb7a
@ -69,11 +69,10 @@ public final class BasicIRBuilder {
|
||||
moduleNode.functions().forEach(functionNode -> dispatchTop(functionNode, irProgram)); // 递归处理模块内的函数
|
||||
case FunctionNode functionNode ->
|
||||
irProgram.add(buildFunction(functionNode)); // 将函数编译成 IRFunction 并加入 IRProgram
|
||||
case StatementNode statementNode -> { // 单条语句(如脚本式 main)
|
||||
FunctionNode functionNode = new FunctionNode("main", List.of(), "void", List.of(statementNode));
|
||||
irProgram.add(buildFunction(functionNode));
|
||||
case StatementNode _ -> {
|
||||
//TODO 单条语句(如脚本式 main)
|
||||
}
|
||||
default -> throw new IllegalStateException("Unsupported top-level node: " + node);
|
||||
default -> throw new IllegalStateException("不支持的顶级节点: " + node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +127,7 @@ public final class BasicIRBuilder {
|
||||
if (r.getExpression().isPresent()) currentFn.add(new ReturnInstruction(expr(r.getExpression().get())));
|
||||
else currentFn.add(new ReturnInstruction(null));
|
||||
}
|
||||
default -> throw new IllegalStateException("Unsupported stmt: " + n);
|
||||
default -> throw new IllegalStateException("不支持的语句: " + n);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,7 +148,7 @@ public final class BasicIRBuilder {
|
||||
if (v == null) throw new IllegalStateException("变量 " + id.name() + " 未定义");
|
||||
yield v;
|
||||
}
|
||||
default -> throw new IllegalStateException("Unsupported expr: " + e);
|
||||
default -> throw new IllegalStateException("不支持的表达式: " + e);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user