Exemplo n.º 1
0
        static OpCodeHandlers()
        {
            var info     = GetData();
            var handlers = new OpCodeHandler[IcedConstants.NumberOfCodeValues];
            int j        = 0;

            for (int i = 0; i < info.Length; i += 3, j++)
            {
                uint          dword1 = info[i];
                OpCodeHandler handler;
                switch ((EncodingKind)((dword1 >> (int)EncFlags1.EncodingShift) & (uint)EncFlags1.EncodingMask))
                {
                case EncodingKind.Legacy:
                    var code = (Code)j;
                    if (code == Code.INVALID)
                    {
                        handler = new InvalidHandler();
                    }
                    else if (code <= Code.DeclareQword)
                    {
                        handler = new DeclareDataHandler(code);
                    }
                    else
                    {
                        handler = new LegacyHandler(dword1, info[i + 1], info[i + 2]);
                    }
                    break;

                case EncodingKind.VEX:
                    handler = new VexHandler(dword1, info[i + 1], info[i + 2]);
                    break;

                case EncodingKind.EVEX:
                    handler = new EvexHandler(dword1, info[i + 1], info[i + 2]);
                    break;

                case EncodingKind.XOP:
                    handler = new XopHandler(dword1, info[i + 1], info[i + 2]);
                    break;

                case EncodingKind.D3NOW:
                    handler = new D3nowHandler(dword1, info[i + 1], info[i + 2]);
                    break;

                default:
                    throw new InvalidOperationException();
                }
                handlers[j] = handler;
            }
            if (j != handlers.Length)
            {
                throw new InvalidOperationException();
            }
            Handlers = handlers;
        }
Exemplo n.º 2
0
        static OpCodeHandlers()
        {
            var encFlags1      = EncoderData.EncFlags1;
            var encFlags2      = EncoderData.EncFlags2;
            var encFlags3Data  = EncoderData.EncFlags3;
            var handlers       = new OpCodeHandler[IcedConstants.CodeEnumCount];
            int i              = 0;
            var invalidHandler = new InvalidHandler();

            for (; i < encFlags1.Length; i++)
            {
                var           encFlags3 = (EncFlags3)encFlags3Data[i];
                OpCodeHandler handler;
                switch ((EncodingKind)(((uint)encFlags3 >> (int)EncFlags3.EncodingShift) & (uint)EncFlags3.EncodingMask))
                {
                case EncodingKind.Legacy:
                    var code = (Code)i;
                    if (code == Code.INVALID)
                    {
                        handler = invalidHandler;
                    }
                    else if (code <= Code.DeclareQword)
                    {
                        handler = new DeclareDataHandler(code);
                    }
                    else
                    {
                        handler = new LegacyHandler((EncFlags1)encFlags1[i], (EncFlags2)encFlags2[i], encFlags3);
                    }
                    break;

                case EncodingKind.VEX:
#if !NO_VEX
                    handler = new VexHandler((EncFlags1)encFlags1[i], (EncFlags2)encFlags2[i], encFlags3);
#else
                    handler = invalidHandler;
#endif
                    break;

                case EncodingKind.EVEX:
#if !NO_EVEX
                    handler = new EvexHandler((EncFlags1)encFlags1[i], (EncFlags2)encFlags2[i], encFlags3);
#else
                    handler = invalidHandler;
#endif
                    break;

                case EncodingKind.XOP:
#if !NO_XOP
                    handler = new XopHandler((EncFlags1)encFlags1[i], (EncFlags2)encFlags2[i], encFlags3);
#else
                    handler = invalidHandler;
#endif
                    break;

                case EncodingKind.D3NOW:
#if !NO_D3NOW
                    handler = new D3nowHandler((EncFlags2)encFlags2[i], encFlags3);
#else
                    handler = invalidHandler;
#endif
                    break;

                default:
                    throw new InvalidOperationException();
                }
                handlers[i] = handler;
            }
            if (i != handlers.Length)
            {
                throw new InvalidOperationException();
            }
            Handlers = handlers;
        }