refactor: 移除 VMCodeGenerator 中的冗余字段
- 删除了 VMCodeGenerator 类中不再使用的 currentFn 字段- 将 currentFn 作为局部变量在 generate 方法中使用 - 这个改动简化了类的结构,减少了冗余代码
This commit is contained in:
parent
1cb5951e68
commit
466b6ca2be
@ -35,12 +35,6 @@ public final class VMCodeGenerator {
|
|||||||
*/
|
*/
|
||||||
private final VMProgramBuilder out;
|
private final VMProgramBuilder out;
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前正在处理的函数名。
|
|
||||||
* 用于区分是否为 main 函数等用途。
|
|
||||||
*/
|
|
||||||
private String currentFn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造 VMCodeGenerator。
|
* 构造 VMCodeGenerator。
|
||||||
*
|
*
|
||||||
@ -72,7 +66,7 @@ public final class VMCodeGenerator {
|
|||||||
* @throws IllegalStateException 如果遇到不支持的 IR 指令类型
|
* @throws IllegalStateException 如果遇到不支持的 IR 指令类型
|
||||||
*/
|
*/
|
||||||
public void generate(IRFunction fn) {
|
public void generate(IRFunction fn) {
|
||||||
this.currentFn = fn.name();
|
String currentFn = fn.name();
|
||||||
out.beginFunction(currentFn);
|
out.beginFunction(currentFn);
|
||||||
for (IRInstruction ins : fn.body()) {
|
for (IRInstruction ins : fn.body()) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user