Exemplo n.º 1
0
        public static PapyrusOpCodes GetPapyrusMathOrEqualityOpCode(Code code, bool isFloat)
        {
            if (InstructionHelper.IsLessThan(code))
            {
                return(PapyrusOpCodes.CmpLt);
            }
            if (InstructionHelper.IsEqualTo(code))
            {
                return(PapyrusOpCodes.CmpEq);
            }
            if (InstructionHelper.IsGreaterThan(code))
            {
                return(PapyrusOpCodes.CmpGt);
            }
            switch (code)
            {
            case Code.Add_Ovf:
            case Code.Add_Ovf_Un:
            case Code.Add:
                return(isFloat ? PapyrusOpCodes.Fadd : PapyrusOpCodes.Iadd);

            case Code.Sub:
            case Code.Sub_Ovf:
            case Code.Sub_Ovf_Un:
                return(isFloat ? PapyrusOpCodes.Fsub : PapyrusOpCodes.Isub);

            case Code.Div_Un:
            case Code.Div:
                return(isFloat ? PapyrusOpCodes.Fdiv : PapyrusOpCodes.Idiv);

            case Code.Mul:
            case Code.Mul_Ovf:
            case Code.Mul_Ovf_Un:
                return(isFloat ? PapyrusOpCodes.Fmul : PapyrusOpCodes.Imul);

            default:
                return(isFloat ? PapyrusOpCodes.Fadd : PapyrusOpCodes.Iadd);
            }
        }