set.java
来自「A compiler for a subset of the Java lang」· Java 代码 · 共 37 行
JAVA
37 行
package inter;import symbols.*;public class Set extends Stmt { public Id id; public Expr expr; public Set(Id i, Expr x) { id = i; expr = x; if ( check(id.type, expr.type) == null ) error("type error"); } public Type check(Type p1, Type p2) { if ( Type.numeric(p1) && Type.numeric(p2) ) return p2; else if ( p1 == Type.Bool && p2 == Type.Bool ) return p2; else return null; } public void gen(int b, int a) { //emit( id.toString() + " = " + expr.gen().toString() ); emit(expr.gen().toString()); if(expr.type == Type.Int) { emit("istore " + id.lvaIdx + "\n"); } else if(expr.type == Type.Float) { emit("fstore " + id.lvaIdx + "\n"); } else if(expr.type == Type.Complex) { emit("fstore " + (id.lvaIdx + 4) + "\n"); emit("fstore " + id.lvaIdx + "\n"); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?