コード例 #1
0
        static bool HandleOperators(string opcodeStr, MetaMidRepresentationOperationFactory operationFactory,
                                    Instruction instruction)
        {
            #region Operators

            if (instruction.OpCode == OpCodes.Add)
            {
                operationFactory.Add();
                return(true);
            }
            if (instruction.OpCode == OpCodes.Sub)
            {
                operationFactory.Sub();
                return(true);
            }
            if (instruction.OpCode == OpCodes.Div)
            {
                operationFactory.Div();
                return(true);
            }
            if (instruction.OpCode == OpCodes.Mul)
            {
                operationFactory.Mul();
                return(true);
            }
            if (instruction.OpCode == OpCodes.Rem)
            {
                operationFactory.Rem();
                return(true);
            }


            if (instruction.OpCode == OpCodes.And)
            {
                operationFactory.And();
                return(true);
            }
            if (instruction.OpCode == OpCodes.Or)
            {
                operationFactory.Or();
                return(true);
            }

            if (instruction.OpCode == OpCodes.Xor)
            {
                operationFactory.Xor();
                return(true);
            }

            #region Unary operators

            if (instruction.OpCode == OpCodes.Not)
            {
                operationFactory.Not();
                return(true);
            }

            if (instruction.OpCode == OpCodes.Neg)
            {
                operationFactory.Neg();
                return(true);
            }

            #endregion

            #region Compare operators

            if (opcodeStr == "cgt" || opcodeStr == "cgt.un")
            {
                operationFactory.Cgt();
                return(true);
            }

            if (opcodeStr == "ceq")
            {
                operationFactory.Ceq();
                return(true);
            }
            if (opcodeStr == "clt")
            {
                operationFactory.Clt();
                return(true);
            }

            #endregion

            #endregion

            return(false);
        }