static void IfStatement(StackFrame frame) { Label falseLabel = new Label(!known); Label endLabel = new Label(!known); Label ifelLabel = new Label(!known); Expect(if_Sym); Expect(lparen_Sym); Condition(); Expect(rparen_Sym); CodeGen.BranchFalse(falseLabel); Statement(frame); CodeGen.Branch(endLabel); falseLabel.Here(); while (la.kind == elseif_Sym) { Get(); Expect(lparen_Sym); Condition(); Expect(rparen_Sym); ifelLabel = new Label(!known); CodeGen.BranchFalse(ifelLabel); Statement(frame); CodeGen.Branch(endLabel); ifelLabel.Here(); } if (la.kind == else_Sym) { Get(); Statement(frame); } endLabel.Here(); }
static void WhileStatement(StackFrame frame) { Label loopExit = new Label(!known); Label loopStart = new Label(known); Expect(while_Sym); Expect(lparen_Sym); Condition(); Expect(rparen_Sym); CodeGen.BranchFalse(loopExit); Statement(frame); CodeGen.Branch(loopStart); loopExit.Here(); }
static void WhileStatement(StackFrame frame) { Label loopExit = new Label(!known); Label loopStart = new Label(known); Expect(while_Sym); Expect(lparen_Sym); Condition(); Expect(rparen_Sym); CodeGen.BranchFalse(loopExit); Statement(frame); if (token.val == ";") { Warning("Can not have an empty statement."); } CodeGen.Branch(loopStart); loopExit.Here(); }