修改为记录模型
This commit is contained in:
parent
a14373b986
commit
b26ff57f4e
@ -19,18 +19,22 @@ public class StatementBuilder {
|
|||||||
this.exprBuilder = new ExpressionBuilder(ctx);
|
this.exprBuilder = new ExpressionBuilder(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 入口:根据不同语句类型分发 */
|
/**
|
||||||
|
* 入口:根据不同语句类型分发
|
||||||
|
*/
|
||||||
public void build(StatementNode stmt) {
|
public void build(StatementNode stmt) {
|
||||||
if (stmt instanceof ExpressionStatementNode es) {
|
if (stmt instanceof ExpressionStatementNode(org.jcnc.snow.compiler.parser.ast.base.ExpressionNode expression)) {
|
||||||
exprBuilder.build(es.expression());
|
exprBuilder.build(expression);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stmt instanceof AssignmentNode an) {
|
if (stmt instanceof AssignmentNode(
|
||||||
IRVirtualRegister vr = exprBuilder.build(an.value());
|
String variable, org.jcnc.snow.compiler.parser.ast.base.ExpressionNode value
|
||||||
if (ctx.getScope().lookup(an.variable()) == null) {
|
)) {
|
||||||
ctx.getScope().declare(an.variable(), vr);
|
IRVirtualRegister vr = exprBuilder.build(value);
|
||||||
|
if (ctx.getScope().lookup(variable) == null) {
|
||||||
|
ctx.getScope().declare(variable, vr);
|
||||||
} else {
|
} else {
|
||||||
ctx.getScope().put(an.variable(), vr);
|
ctx.getScope().put(variable, vr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user