Example #1
0
        public static UnaryOperator  UnaryOp(this AnyInstruction instr, uint bcv)
        {
            if (bcv > 0xE)
            {
                switch (instr.OpCode.VersionF)
                {
                case FOpCode.Neg:
                    return(UnaryOperator.Negation);

                case FOpCode.Not:
                    return(UnaryOperator.Complement);

                case FOpCode.Ret:
                    return(UnaryOperator.Return);

                case FOpCode.Exit:
                    return(UnaryOperator.Exit);

                case FOpCode.Conv:
                    return(UnaryOperator.Convert);

                case FOpCode.Dup:
                    return(UnaryOperator.Duplicate);
                }
            }
            else
            {
                switch (instr.OpCode.VersionE)
                {
                case EOpCode.Neg:
                    return(UnaryOperator.Negation);

                case EOpCode.Not:
                    return(UnaryOperator.Complement);

                case EOpCode.Ret:
                    return(UnaryOperator.Return);

                case EOpCode.Exit:
                    return(UnaryOperator.Exit);

                case EOpCode.Conv:
                    return(UnaryOperator.Convert);

                case EOpCode.Dup:
                    return(UnaryOperator.Duplicate);
                }
            }

            return(0);
        }
Example #2
0
        public static ExpressionType ExprType(this AnyInstruction instr, uint bcv)
        {
            if (bcv > 0xE)
            {
                switch (instr.OpCode.VersionF)
                {
                case FOpCode.PushCst:
                case FOpCode.PushGlb:
                case FOpCode.PushVar:
                case FOpCode.PushI16:
                case FOpCode.PushLoc:
                    return(instr.Push.Type == DataType.Variable ? ExpressionType.Variable : ExpressionType.Literal);

                case FOpCode.Set:
                    return(ExpressionType.Set);

                case FOpCode.Call:
                    return(ExpressionType.Call);
                }
            }
            else
            {
                switch (instr.OpCode.VersionE)
                {
                case EOpCode.Push:
                    return(instr.Push.Type == DataType.Variable ? ExpressionType.Variable : ExpressionType.Literal);

                case EOpCode.Set:
                    return(ExpressionType.Set);

                case EOpCode.Call:
                    return(ExpressionType.Call);
                }
            }

            if (instr.UnaryOp(bcv) != 0)
            {
                return(ExpressionType.UnaryOp);
            }
            if (instr.BinaryOp(bcv) != 0)
            {
                return(ExpressionType.BinaryOp);
            }

            return(0);
        }
Example #3
0
 public static InstructionKind Kind(this AnyInstruction instr, uint bcv) => instr.OpCode.Kind(bcv);
Example #4
0
 public static uint            Rest(this AnyInstruction instr) => instr.InstrData & 0x00FFFFFF;
Example #5
0
        public static BinaryOperator BinaryOp(this AnyInstruction instr, uint bcv)
        {
            if (bcv > 0xE)
            {
                switch (instr.OpCode.VersionF)
                {
                case FOpCode.Add:
                    return(BinaryOperator.Addition);

                case FOpCode.Sub:
                    return(BinaryOperator.Subtraction);

                case FOpCode.Mul:
                    return(BinaryOperator.Multiplication);

                case FOpCode.Div:
                    return(BinaryOperator.Division);

                case FOpCode.Rem:
                    return(BinaryOperator.Remainder);

                case FOpCode.Mod:
                    return(BinaryOperator.Modulo);

                case FOpCode.And:
                    return(BinaryOperator.And);

                case FOpCode.Or:
                    return(BinaryOperator.Or);

                case FOpCode.Xor:
                    return(BinaryOperator.Xor);

                case FOpCode.Shl:
                    return(BinaryOperator.LeftShift);

                case FOpCode.Shr:
                    return(BinaryOperator.RightShift);

                case FOpCode.Cmp:
                    switch (instr.DoubleType.ComparisonType)
                    {
                    case ComparisonType.Equality:
                        return(BinaryOperator.Equality);

                    case ComparisonType.Inequality:
                        return(BinaryOperator.Inequality);

                    case ComparisonType.GreaterThan:
                        return(BinaryOperator.GreaterThan);

                    case ComparisonType.LowerThan:
                        return(BinaryOperator.LowerThan);

                    case ComparisonType.GTOrEqual:
                        return(BinaryOperator.GTOrEqual);

                    case ComparisonType.LTOrEqual:
                        return(BinaryOperator.LTOrEqual);
                    }

                    return(0);    // ?
                }
            }
            else
            {
                switch (instr.OpCode.VersionE)
                {
                case EOpCode.Add:
                    return(BinaryOperator.Addition);

                case EOpCode.Sub:
                    return(BinaryOperator.Subtraction);

                case EOpCode.Mul:
                    return(BinaryOperator.Multiplication);

                case EOpCode.Div:
                    return(BinaryOperator.Division);

                case EOpCode.Rem:
                    return(BinaryOperator.Remainder);

                case EOpCode.Mod:
                    return(BinaryOperator.Modulo);

                case EOpCode.And:
                    return(BinaryOperator.And);

                case EOpCode.Or:
                    return(BinaryOperator.Or);

                case EOpCode.Xor:
                    return(BinaryOperator.Xor);

                case EOpCode.Shl:
                    return(BinaryOperator.LeftShift);

                case EOpCode.Shr:
                    return(BinaryOperator.RightShift);

                case EOpCode.Ceq:
                    return(BinaryOperator.Equality);

                case EOpCode.Cne:
                    return(BinaryOperator.Inequality);

                case EOpCode.Cgt:
                    return(BinaryOperator.GreaterThan);

                case EOpCode.Clt:
                    return(BinaryOperator.LowerThan);

                case EOpCode.Cge:
                    return(BinaryOperator.GTOrEqual);

                case EOpCode.Cle:
                    return(BinaryOperator.LTOrEqual);
                }
            }

            return(0);
        }