コード例 #1
0
        public static bool FindOpcodeInfo(OpCount count, byte opnum, out OpcodeInfo result)
        {
            Dictionary <byte, OpcodeInfo> dict;

            switch (count)
            {
            case OpCount.Zero:
                dict = zeroOpInfos;
                break;

            case OpCount.One:
                dict = oneOpInfos;
                break;

            case OpCount.Two:
                dict = twoOpInfos;
                break;

            case OpCount.Var:
                dict = varOpInfos;
                break;

            case OpCount.Ext:
                dict = extOpInfos;
                break;

            default:
                throw new ArgumentOutOfRangeException("count");
            }

            return(dict.TryGetValue(opnum, out result));
        }
コード例 #2
0
ファイル: Opcodes.cs プロジェクト: hackerlank/zlr
        public static bool FindOpcodeInfo(OpCount count, byte opnum, byte zversion, out OpcodeInfo result)
        {
            Dictionary <byte, OpcodeInfo[]> dict;

            switch (count)
            {
            case OpCount.Zero:
                dict = zeroOpInfos;
                break;

            case OpCount.One:
                dict = oneOpInfos;
                break;

            case OpCount.Two:
                dict = twoOpInfos;
                break;

            case OpCount.Var:
                dict = varOpInfos;
                break;

            case OpCount.Ext:
                dict = extOpInfos;
                break;

            default:
                throw new ArgumentOutOfRangeException("count");
            }

            OpcodeInfo[] array;
            if (dict.TryGetValue(opnum, out array))
            {
                foreach (OpcodeInfo info in array)
                {
                    if (zversion >= info.Attr.MinVersion && zversion <= info.Attr.MaxVersion)
                    {
                        result = info;
                        return(true);
                    }
                }
            }

            result = default(OpcodeInfo);
            return(false);
        }
コード例 #3
0
        private static void InitOpcodeTable()
        {
            MethodInfo[] mis = typeof(Opcode).GetMethods(
                BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (MethodInfo mi in mis)
            {
                OpcodeAttribute[] attrs = (OpcodeAttribute[])mi.GetCustomAttributes(typeof(OpcodeAttribute), false);
                if (attrs.Length > 0)
                {
                    OpcodeCompiler del = (OpcodeCompiler)Delegate.CreateDelegate(
                        typeof(OpcodeCompiler), null, mi);
                    OpcodeAttribute a    = attrs[0];
                    OpcodeInfo      info = new OpcodeInfo(a, del);
                    switch (a.OpCount)
                    {
                    case OpCount.Zero:
                        zeroOpInfos.Add((byte)(a.Number - 176), info);
                        break;

                    case OpCount.One:
                        oneOpInfos.Add((byte)(a.Number - 128), info);
                        break;

                    case OpCount.Two:
                        twoOpInfos.Add(a.Number, info);
                        break;

                    case OpCount.Var:
                        varOpInfos.Add((byte)(a.Number - 224), info);
                        break;

                    case OpCount.Ext:
                        extOpInfos.Add(a.Number, info);
                        break;
                    }
                }
            }
        }
コード例 #4
0
ファイル: Opcodes.cs プロジェクト: zerodowned/angelisland
        public static bool FindOpcodeInfo(OpCount count, byte opnum, out OpcodeInfo result)
        {
            Dictionary<byte, OpcodeInfo> dict;

            switch (count)
            {
                case OpCount.Zero:
                    dict = zeroOpInfos;
                    break;
                case OpCount.One:
                    dict = oneOpInfos;
                    break;
                case OpCount.Two:
                    dict = twoOpInfos;
                    break;
                case OpCount.Var:
                    dict = varOpInfos;
                    break;
                case OpCount.Ext:
                    dict = extOpInfos;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("count");
            }

            return dict.TryGetValue(opnum, out result);
        }
コード例 #5
0
ファイル: Opcodes.cs プロジェクト: zerodowned/angelisland
        private static void InitOpcodeTable()
        {
            MethodInfo[] mis = typeof(Opcode).GetMethods(
                BindingFlags.NonPublic|BindingFlags.Instance);

            foreach (MethodInfo mi in mis)
            {
                OpcodeAttribute[] attrs = (OpcodeAttribute[])mi.GetCustomAttributes(typeof(OpcodeAttribute), false);
                if (attrs.Length > 0)
                {
                    OpcodeCompiler del = (OpcodeCompiler)Delegate.CreateDelegate(
                        typeof(OpcodeCompiler), null, mi);
                    OpcodeAttribute a = attrs[0];
                    OpcodeInfo info = new OpcodeInfo(a, del);
                    switch (a.OpCount)
                    {
                        case OpCount.Zero:
                            zeroOpInfos.Add((byte)(a.Number - 176), info);
                            break;
                        case OpCount.One:
                            oneOpInfos.Add((byte)(a.Number - 128), info);
                            break;
                        case OpCount.Two:
                            twoOpInfos.Add(a.Number, info);
                            break;
                        case OpCount.Var:
                            varOpInfos.Add((byte)(a.Number - 224), info);
                            break;
                        case OpCount.Ext:
                            extOpInfos.Add(a.Number, info);
                            break;
                    }
                }
            }
        }
コード例 #6
0
ファイル: Opcodes.cs プロジェクト: hackerlank/zlr
        private static void InitOpcodeTable()
        {
            MethodInfo[] mis = typeof(Opcode).GetMethods(
                BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (MethodInfo mi in mis)
            {
                OpcodeAttribute[] attrs = (OpcodeAttribute[])mi.GetCustomAttributes(typeof(OpcodeAttribute), false);
                if (attrs.Length > 0)
                {
                    OpcodeCompiler del = (OpcodeCompiler)Delegate.CreateDelegate(
                        typeof(OpcodeCompiler), null, mi);
                    foreach (OpcodeAttribute a in attrs)
                    {
                        OpcodeInfo info = new OpcodeInfo(a, del);

                        byte num;
                        Dictionary <byte, OpcodeInfo[]> dict;

                        switch (a.OpCount)
                        {
                        case OpCount.Zero:
                            dict = zeroOpInfos;
                            num  = (byte)(a.Number - 176);
                            break;

                        case OpCount.One:
                            dict = oneOpInfos;
                            num  = (byte)(a.Number - 128);
                            break;

                        case OpCount.Two:
                            dict = twoOpInfos;
                            num  = a.Number;
                            break;

                        case OpCount.Var:
                            dict = varOpInfos;
                            num  = (byte)(a.Number - 224);
                            break;

                        case OpCount.Ext:
                            dict = extOpInfos;
                            num  = a.Number;
                            break;

                        default:
                            throw new Exception("BUG:BADOPCOUNT");
                        }

                        OpcodeInfo[] array;
                        if (dict.TryGetValue(num, out array) == false)
                        {
                            array = new OpcodeInfo[] { info };
                            dict.Add(num, array);
                        }
                        else
                        {
                            OpcodeInfo[] newArray = new OpcodeInfo[array.Length + 1];
                            Array.Copy(array, newArray, array.Length);
                            newArray[newArray.Length - 1] = info;
                            dict[num] = newArray;
                        }
                    }
                }
            }
        }