示例#1
0
        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");
            }
        }
示例#2
0
 private string GenerateOperation(BinaryInstruction instruction, string op)
 {
     return(instruction.arg2 + " " + op + " " + instruction.arg1 + ";\n");
 }