Read Chapter 7.
ExpTy transExp (Absyn.IntExp e) { return new ExpTy(trans.intExp(e.value), INT); }Instead of returning "null" as the result of translation to intermediate code, each method calls a helper method in Translate.Translate to convert the AST to intermediate code. The corresponding method in Translate.Translate in our example is:
public Exp intExp (int i) { return new Ex (new Tree.CONST(i)); }
... private Temp.Label breakScope; ... ExpTy transExp (Absyn.BreakExp e) { ... // check if properly nested return new ExpTy(trans.breakExp(breakScope), VOID); }In Translate.Translate, we would then have:
public Exp breakExp (Temp.Label lab) { return new Nx(new Tree.JUMP(lab)); }which would translate a "break" as a jump to the label of the enclosing loop.