jdk改成21
This commit is contained in:
parent
2590dd46fb
commit
fa5786d907
@ -61,27 +61,27 @@ public class SnowCompiler {
|
||||
System.out.println(program);
|
||||
|
||||
/* 5. 后端:寄存器分配 & 代码生成 + VM 执行 */
|
||||
for (IRFunction fn : program.functions()) {
|
||||
var alloc = new RegisterAllocator();
|
||||
var slotM = alloc.allocate(fn);
|
||||
|
||||
var gen = new VMCodeGenerator(slotM);
|
||||
var code = gen.generate(fn);
|
||||
|
||||
System.out.println("== VM code for " + fn.name() + " ==");
|
||||
code.forEach(System.out::println);
|
||||
|
||||
|
||||
/* 只执行 main 函数 */
|
||||
if ("main".equals(fn.name())) {
|
||||
VirtualMachineEngine vm = new VirtualMachineEngine(VMMode.RUN);
|
||||
|
||||
vm.execute(code); // 运行指令
|
||||
vm.printStack(); // 打印 Operand-/Call-Stack
|
||||
vm.printLocalVariables(); // 打印局部变量槽
|
||||
|
||||
System.out.println("Process has ended");
|
||||
}
|
||||
}
|
||||
// for (IRFunction fn : program.functions()) {
|
||||
// var alloc = new RegisterAllocator();
|
||||
// var slotM = alloc.allocate(fn);
|
||||
//
|
||||
// var gen = new VMCodeGenerator(slotM);
|
||||
// var code = gen.generate(fn);
|
||||
//
|
||||
// System.out.println("== VM code for " + fn.name() + " ==");
|
||||
// code.forEach(System.out::println);
|
||||
//
|
||||
//
|
||||
// /* 只执行 main 函数 */
|
||||
// if ("main".equals(fn.name())) {
|
||||
// VirtualMachineEngine vm = new VirtualMachineEngine(VMMode.RUN);
|
||||
//
|
||||
// vm.execute(code); // 运行指令
|
||||
// vm.printStack(); // 打印 Operand-/Call-Stack
|
||||
// vm.printLocalVariables(); // 打印局部变量槽
|
||||
//
|
||||
// System.out.println("Process has ended");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,8 +87,8 @@ public final class BasicIRBuilder {
|
||||
variables.clear(); // 清空变量表(每个函数独立)
|
||||
|
||||
// 将函数参数映射为新的寄存器(未进一步使用参数,但保留未来拓展空间)
|
||||
for (ParameterNode p : functionNode.parameters()) {
|
||||
variables.put(p.name(), currentFn.newRegister());
|
||||
for (ParameterNode parameterNode : functionNode.parameters()) {
|
||||
variables.put(parameterNode.name(), currentFn.newRegister());
|
||||
}
|
||||
|
||||
// 编译函数体中的每条语句
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user