public override Address GenerateCode(List <Instruction> instructions) { Left.GenerateCode(instructions); TrueList.AddRange(Left.TrueList); Right.GenerateCode(instructions); TrueList.AddRange(Right.TrueList); FalseList.AddRange(Right.FalseList); return(base.GenerateCode(instructions)); }
public override Address GenerateCode(List <Instruction> instructions) { Label rightLabel = new Label(); Left.GenerateCode(instructions); FalseList.AddRange(Left.FalseList); Left.Backpatch(rightLabel, null); instructions.Add(new LabelInstruction(rightLabel)); Right.GenerateCode(instructions); TrueList.AddRange(Right.TrueList); FalseList.AddRange(Right.FalseList); return(base.GenerateCode(instructions)); }
public override Address GenerateCode(List <Instruction> instructions) { Address address1 = Left.GenerateCode(instructions); Address address2 = Right.GenerateCode(instructions); Address result = new Address(); IfJumpInstruction falseInstruction = new IfJumpInstruction(address1, OppositeRelOpAsString, address2, null); instructions.Add(falseInstruction); FalseList.Add(falseInstruction); IfJumpInstruction trueInstruction = new IfJumpInstruction(address1, RelOpAsString, address2, null); instructions.Add(trueInstruction); TrueList.Add(trueInstruction); return(result); }