if ( a < b && c < d ) { ... true block with label t } else { ... false block with label f }translates to
let z = new Label() in new SEQ(new CJUMP(CJUMP.LT, translate(a), translate(b), z, f), new SEQ(new LABEL(z), new CJUMP(CJUMP.LT, translate(c), translate(d), t, f)))
flag = a < b && c < d;translates to
let r = new Temp(), t = new Label(), f = new Label() in new ESEQ(new SEQ(new MOVE(new TEMP(r), new CONST(1)), new SEQ(translate(a < b && c < d, t, f), new SEQ(new LABEL(f), new SEQ(new MOVE(new TEMP(r), new CONST(0)), new LABEL(t))))), new TEMP(r))
new MEM(new BINOP(PLUS, new TEMP(fp), new CONST(k)))where fp is defined by class Frame and k is the offset for v in the frame (again defined by class Frame)
new MEM(new BINOP(PLUS, translate(a), new BINOP(MUL, translate(i), new CONST(w))))where w is the word size
if e1 then e2 else e3This is an ML issue and isn't relevant for MiniJava.
new CALL(new NAME(lf), [arguments])where lf is the label for function f
new CALL(new NAME(lC$m), [p, ...args...])
test: if not(condition) goto done body goto test done:
for(init; expr; update) bodyto
init; while ( expr ) { body update }
for i := low to high do bodybecomes
temp = high i = low if i > temp goto done top: body if i >= temp goto done i = i + 1 goto top
MEM(BINOP(PLUS, CONST(kn), MEM(BINOP(PLUS, CONST(kn-1), ... MEM(BINOP(PLUS, CONST(k1), TEMP(fp))) ... ))))(note no new's)
[prologue:]
[epilogue:]