private string GenerateBinary(BinaryInstruction instruction) { switch (instruction.op) { case Operator.ADDITION: return(GenerateOperation(instruction, "+=")); case Operator.SUBTRACTION: return(GenerateOperation(instruction, "-=")); case Operator.DIVISION: return(GenerateOperation(instruction, "/=")); case Operator.MULTIPLICATION: return(GenerateOperation(instruction, "*=")); default: throw new Exception("unrecognzed operator"); } }
private string GenerateOperation(BinaryInstruction instruction, string op) { return(instruction.arg2 + " " + op + " " + instruction.arg1 + ";\n"); }