public void outAAndexpExp(AAndexpExp node) { Exp lhs = (Exp) getOut(node.getLeft()); Exp rhs = (Exp) getOut(node.getRight()); Label t = new Label(); Label f = new Label(); Label join = new Label(); Label reallyTrue = new Label(); // first check the lhs expression. If true, the t label will mark // the second check CJUMP firstCheck = new CJUMP(CJUMP.EQ, lhs, new CONST(1),t,f); CJUMP secondCheck = new CJUMP(CJUMP.EQ,rhs, new CONST(1),reallyTrue, f); // Result is the 0/1 (true/false) result of the boolean expression Temp result = new Temp(); // Now we build the tree by attaching labels and jumps SEQ tCase = new SEQ(new LABEL(t),secondCheck); SEQ reallyTrueCase = new SEQ(new LABEL(reallyTrue), new SEQ(new MOVE(new TEMP(result), new CONST(1)), new JUMP(join))); SEQ fCase = new SEQ(new LABEL(f),new MOVE(new TEMP(result), new CONST(0))); SEQ joinIt = new SEQ(firstCheck, new SEQ(tCase, new SEQ(reallyTrueCase, new SEQ(fCase, new LABEL(join))))); setOut(node, new ESEQ(joinIt, new TEMP(result))); defaultOut(node); }