示例#1
0
 public static string ToPrettyString(this OpCodes type, int bcv) => bcv > 0xE ? type.VersionF.ToPrettyString() : type.VersionE.ToString().ToLowerInvariant();
示例#2
0
        public static GeneralOpCode General(this OpCodes code, uint bcv)
        {
            if (bcv > 0xE)
            {
                switch (code.VersionF)
                {
                case FOpCode.Conv:
                    return(GeneralOpCode.Conv);

                case FOpCode.Mul:
                    return(GeneralOpCode.Mul);

                case FOpCode.Div:
                    return(GeneralOpCode.Div);

                case FOpCode.Rem:
                    return(GeneralOpCode.Rem);

                case FOpCode.Mod:
                    return(GeneralOpCode.Mod);

                case FOpCode.Add:
                    return(GeneralOpCode.Add);

                case FOpCode.Sub:
                    return(GeneralOpCode.Sub);

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

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

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

                case FOpCode.Neg:
                    return(GeneralOpCode.Neg);

                case FOpCode.Not:
                    return(GeneralOpCode.Not);

                case FOpCode.Shl:
                    return(GeneralOpCode.Shl);

                case FOpCode.Shr:
                    return(GeneralOpCode.Shr);

                case FOpCode.Cmp:
                    return(GeneralOpCode.Cmp);

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

                case FOpCode.Dup:
                    return(GeneralOpCode.Dup);

                case FOpCode.Ret:
                    return(GeneralOpCode.Ret);

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

                case FOpCode.Pop:
                    return(GeneralOpCode.Pop);

                case FOpCode.Br:
                    return(GeneralOpCode.Br);

                case FOpCode.Brt:
                    return(GeneralOpCode.Brt);

                case FOpCode.Brf:
                    return(GeneralOpCode.Brf);

                case FOpCode.PushEnv:
                    return(GeneralOpCode.PushEnv);

                case FOpCode.PopEnv:
                    return(GeneralOpCode.PopEnv);

                case FOpCode.PushCst:
                case FOpCode.PushLoc:
                case FOpCode.PushGlb:
                case FOpCode.PushVar:
                case FOpCode.PushI16:
                    return(GeneralOpCode.Push);

                case FOpCode.Call:
                    return(GeneralOpCode.Call);

                case FOpCode.Break:
                    return(GeneralOpCode.Break);

                default:
                    return(0);
                }
            }

            switch (code.VersionE)
            {
            case EOpCode.Ceq:
            case EOpCode.Cge:
            case EOpCode.Cgt:
            case EOpCode.Cle:
            case EOpCode.Clt:
            case EOpCode.Cne:
                return(GeneralOpCode.Cmp);

            default:
                return((GeneralOpCode)code.VersionE);
            }
        }
示例#3
0
        public static InstructionKind Kind(this OpCodes code, uint bcv)
        {
            if (bcv > 0xE)
            {
                switch (code.VersionF)
                {
                case FOpCode.Set:
                    return(InstructionKind.Set);

                case FOpCode.PushCst:
                case FOpCode.PushLoc:
                case FOpCode.PushGlb:
                case FOpCode.PushVar:
                case FOpCode.PushI16:
                    return(InstructionKind.Push);

                case FOpCode.Call:
                    return(InstructionKind.Call);

                case FOpCode.Break:
                    return(InstructionKind.Break);

                case FOpCode.Conv:
                case FOpCode.Mul:
                case FOpCode.Div:
                case FOpCode.Rem:
                case FOpCode.Mod:
                case FOpCode.Add:
                case FOpCode.Sub:
                case FOpCode.And:
                case FOpCode.Or:
                case FOpCode.Xor:
                case FOpCode.Not:
                case FOpCode.Shl:
                case FOpCode.Shr:
                case FOpCode.Cmp:
                    return(InstructionKind.DoubleType);

                case FOpCode.Dup:
                case FOpCode.Neg:
                case FOpCode.Ret:
                case FOpCode.Exit:
                case FOpCode.Pop:
                    return(InstructionKind.SingleType);

                case FOpCode.Br:
                case FOpCode.Brt:
                case FOpCode.Brf:
                case FOpCode.PushEnv:
                case FOpCode.PopEnv:
                    return(InstructionKind.Goto);
                }
            }
            else
            {
                switch (code.VersionE)
                {
                case EOpCode.Set:
                    return(InstructionKind.Set);

                case EOpCode.Push:
                    return(InstructionKind.Push);

                case EOpCode.Call:
                    return(InstructionKind.Call);

                case EOpCode.Break:
                    return(InstructionKind.Break);

                case EOpCode.Conv:
                case EOpCode.Mul:
                case EOpCode.Div:
                case EOpCode.Rem:
                case EOpCode.Mod:
                case EOpCode.Add:
                case EOpCode.Sub:
                case EOpCode.And:
                case EOpCode.Or:
                case EOpCode.Xor:
                case EOpCode.Not:
                case EOpCode.Shl:
                case EOpCode.Shr:
                case EOpCode.Clt:
                case EOpCode.Cle:
                case EOpCode.Ceq:
                case EOpCode.Cne:
                case EOpCode.Cge:
                case EOpCode.Cgt:
                    return(InstructionKind.DoubleType);

                case EOpCode.Dup:
                case EOpCode.Neg:
                case EOpCode.Ret:
                case EOpCode.Exit:
                case EOpCode.Pop:
                    return(InstructionKind.SingleType);

                case EOpCode.Br:
                case EOpCode.Brt:
                case EOpCode.Brf:
                case EOpCode.PushEnv:
                case EOpCode.PopEnv:
                    return(InstructionKind.Goto);
                }
            }

            throw new ArgumentOutOfRangeException(nameof(code));
        }