Exemple #1
0
 public Instructions()
 {
     instructions["ST"]   = new ST();
     instructions["LD"]   = new LD();
     instructions["ADD"]  = new ADD();
     instructions["SUB"]  = new SUB();
     instructions["JMP"]  = new JMP();
     instructions["JN"]   = new JN();
     instructions["JP"]   = new JP();
     instructions["JZ"]   = new JZ();
     instructions["JNZ"]  = new JNZ();
     instructions["HALT"] = new HALT();
     //Second architecture functions.
     instructions["LD2"] = new LD2();
     instructions["LD3"] = new LD3();
     instructions["ST2"] = new ST2();
     instructions["ST3"] = new ST3();
     instructions["POS"] = new POS();
     instructions["PXL"] = new PXL();
     instructions["RND"] = new RND();
     instructions["CLR"] = new CLR();
     instructions["COS"] = new COS();
     instructions["SIN"] = new SIN();
     instructions["IN"]  = new IN();
 }
Exemple #2
0
        public void FreeCommonLanguageRuntime()
        {
            this.ThrowIfDisposed();

            if (this.Clr == null)
            {
                return;
            }

            if (this.Clr.ppClrHost != IntPtr.Zero &&
                this.Clr.Stop != null &&
                this.Clr.Release != null)
            {
                try
                {
                    uint status = this.Clr.Stop(this.Clr.ppClrHost);

                    if (status != Win32.ERROR_SUCCESS)
                    {
                        throw new Win32Exception((int)status);
                    }
                }
                finally
                {
                    this.Clr.Release(this.Clr.ppClrHost);
                }
            }

            if (this.Clr.pMSCorEE != null)
            {
                this.Clr.pMSCorEE.Dispose();
            }

            this.Clr = null;
        }
Exemple #3
0
        private static void InitializeArray(Array array, IField field)
        {
            var elemType = array.GetType().GetElementType();

            var vals = CLR.ReadArrayValues(field, Type.GetTypeCode(elemType));

            if (array.Rank == 1)
            {
                int n = vals.Count;
                for (int i = 0; i < n; ++i)
                {
                    array.SetValue(vals[i], i);
                }
            }
            else
            {
                int i  = 0;
                var it = new ArrayIterator(array);
                while (it.MoveNext())
                {
                    array.SetValue(vals[i], it.Indices);
                    i++;
                }
            }
        }
Exemple #4
0
        public void CLRExecuteAreEqual()
        {
            string constResult = "Выполнение приложения";
            CLR    component   = new CLR();
            string result;

            result = component.Execute();

            Assert.AreEqual(constResult, result);
        }
Exemple #5
0
        public void CLRFinishAreEqual()
        {
            string constResult = "Завершение работы приложения";
            CLR    component   = new CLR();
            string result;

            result = component.Finish();

            Assert.AreEqual(constResult, result);
        }
        private void FacadeStart(object sender, RoutedEventArgs e)
        {
            TextEditor textEditor = new TextEditor();
            Compiller  compiller  = new Compiller();
            CLR        clr        = new CLR();

            VisualStudioFacade ide = new VisualStudioFacade(textEditor, compiller, clr);

            Facade.Programmer programmer = new Facade.Programmer();
            MessageBox.Show(programmer.CreateApplication(ide));
        }
Exemple #7
0
        //private Dictionary<MethodReference, MethodData> _methods;

        public Module(ModuleDefinition cilModule, string target)
        {
            this._cilModule             = cilModule;
            this._target                = target;
            this._llModule              = new LLVM.Module(cilModule.Name);
            this._llModule.TargetTriple = target;
            CLR.Initialize(this._llModule);

            _types = new Dictionary <TypeReference, Type>();
            //_methods = new Dictionary<MethodReference, MethodData>();
        }
        static void Main(string[] args)
        {
            TextEditor textEditor = new TextEditor();
            Compiler   compiller  = new Compiler();
            CLR        clr        = new CLR();

            IDEFacade ide = new IDEFacade(textEditor, compiller, clr);

            Programmer programmer = new Programmer();

            programmer.CreateApplication(ide);
        }
Exemple #9
0
        public async Task <DataContent> GetContentAsync()
        {
            if (VirtualAddress == 0 || Size == 0)
            {
                return(null);
            }

            switch (DirectoryType)
            {
            case DataDirectoryType.LoadConfigTable:
                return(await LoadConfigurationDirectory.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.TLSTable:
                return(await TLSDirectory.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.CertificateTable:
                return(await Certificate.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.CLRRuntimeHeader:
                return(await CLR.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.Debug:
                return(await DebugDirectory.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.BaseRelocationTable:
                return(await RelocationTable.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.ExportTable:
                return(await ExportDirectory.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.ImportTable:
                return(await ImportDirectory.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.DelayImportDescriptor:
                return(await DelayedImportDirectory.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.ExceptionTable:
                return(await ExceptionTable.GetAsync(_image).ConfigureAwait(false));

            case DataDirectoryType.ResourceTable:
                return(await ResourceDirectory.GetAsync(_image).ConfigureAwait(false));

            default:
            {
                var calc       = _image.GetCalculator();
                var fileOffset = calc.RVAToOffset(VirtualAddress);
                var va         = _imageBase + VirtualAddress;
                var location   = new Location(_image, fileOffset, VirtualAddress, va, Size, Size);

                return(new DataContent(_image, this, location));
            }
            }
        }
Exemple #10
0
        public void Implementation()
        {
            var textEditor = new TextEditor();
            var compiller  = new Compiller();
            var clr        = new CLR();

            var ide = new VisualStudioFacade(textEditor, compiller, clr);

            var programmer = new Programmer();

            programmer.CreateApplication(ide);
        }
        public static void Display()
        {
            TextEditor textEditor = new TextEditor();
            Compiller  compiller  = new Compiller();
            CLR        clr        = new CLR();

            VisualStudioFacade ide = new VisualStudioFacade(textEditor, compiller, clr);

            Programmer programmer = new Programmer();

            programmer.CreateApplication(ide);
        }
Exemple #12
0
        public void IDEFacadeFinishAreEqual()
        {
            TextEditor textEditor = new TextEditor();
            Compilier  compilier  = new Compilier();
            CLR        clr        = new CLR();

            string    constResult = clr.Finish();
            IDEFacade component   = new IDEFacade(textEditor, compilier, clr);
            string    result;

            result = component.Finish();

            Assert.AreEqual(constResult, result);
        }
Exemple #13
0
        public override string ToString()
        {
            OperatingSystem os   = System.Environment.OSVersion;
            Version         v    = System.Environment.Version;
            string          wote = "dev: " + DEVICE.ToString() +
                                   "\r\nos: " + OS.ToString() +
                                   "\r\nclr: " + CLR.ToString() +
                                   "\r\n" +
                                   "\r\nplat: " + System.Environment.OSVersion.Platform.ToString() +
                                   "\r\nos: " + System.Environment.OSVersion.ToString() +
                                   "\r\nver:" + System.Environment.Version.ToString();

            return(wote);
        }
Exemple #14
0
        static void Main(string[] args)
        {
            TextEditor textEditor = new TextEditor();
            Compiller  compiller  = new Compiller();
            CLR        clr        = new CLR();

            VisualStudioFacade ide = new VisualStudioFacade(textEditor, compiller, clr);

            Programmer programmer = new Programmer();

            programmer.CreateApplication(ide);

            Console.Read();
        }
Exemple #15
0
        public void IDEFacadeStartAreEqual()
        {
            TextEditor textEditor = new TextEditor();
            Compilier  compilier  = new Compilier();
            CLR        clr        = new CLR();

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(textEditor.CreateCode());
            stringBuilder.Append(textEditor.SaveCode());
            stringBuilder.Append(compilier.Compile());
            stringBuilder.Append(clr.Execute());

            string    constResult = stringBuilder.ToString();
            IDEFacade component   = new IDEFacade(textEditor, compilier, clr);
            string    result;

            result = component.Start();

            Assert.AreEqual(constResult, result);
        }
Exemple #16
0
        private NumericStackType StackTypeForTypeSpec(CLR.CLRTypeSpec typeSpec)
        {
            if (typeSpec is CLR.CLRTypeSpecClass)
            {
                CLR.CLRTypeSpecClass asClass = (CLR.CLRTypeSpecClass)typeSpec;
                if (asClass.TypeDef.ContainerClass == null && asClass.TypeDef.TypeNamespace == "System")
                {
                    string typeName = asClass.TypeDef.TypeName;
                    if (typeName == "Char" ||
                        typeName == "Boolean" ||
                        typeName == "Byte" ||
                        typeName == "SByte" ||
                        typeName == "Int16" ||
                        typeName == "UInt16" ||
                        typeName == "Int32" ||
                        typeName == "UInt32")
                        return NumericStackType.Int32;
                    if (typeName == "Int64" || typeName == "UInt64")
                        return NumericStackType.Int64;
                    if (typeName == "IntPtr" || typeName == "UIntPtr")
                        return NumericStackType.NativeInt;
                    if (typeName == "Single")
                        return NumericStackType.Float32;
                    if (typeName == "Double")
                        return NumericStackType.Float64;
                }

                CppClass typeClass = m_builder.GetCachedClass(typeSpec);
                if (typeClass.IsEnum)
                    return StackTypeForTypeSpec(typeClass.GetEnumUnderlyingType());
            }
            throw new Exception("Unrecognized numeric type spec");
        }
Exemple #17
0
 public AnonymousInstruction2(CLR parent)
 {
     this.parent = parent;
 }
Exemple #18
0
 public RiderFacade(TextEditor textEditor, Compiler compiler, CLR clr)
 {
     _textEditor = textEditor;
     _compiler   = compiler;
     _clr        = clr;
 }
 public VisualStudioFacade(TextEditor te, Compiller compil, CLR clr)
 {
     this.textEditor = te;
     this.compiller  = compil;
     this.clr        = clr;
 }
Exemple #20
0
        static void Main(string[] args)
        {
            #region Creational
            //-Factory Method-
            Developer dev    = new PanelDeveloper("ООО КирпичСтрой");
            House     house2 = dev.Create();
            dev = new WoodDeveloper("Частный застройщик");
            House house = dev.Create();

            //-Abstract Factory-
            GofPatterns.Creational.Hero elf = new GofPatterns.Creational.Hero(new ElfFactory());
            elf.Hit();
            elf.Run();
            GofPatterns.Creational.Hero voin = new GofPatterns.Creational.Hero(new VoinFactory());
            voin.Hit();
            voin.Run();

            //-Singleton-
            Computer comp = new Computer();
            comp.Launch("Windows 8.1");
            Console.WriteLine(comp.OS.Name);

            // у нас не получится изменить ОС, так как объект уже создан
            comp.OS = OS.getInstance("Windows 10");

            //-Prototype-
            IFigure figure       = new Rectangle(30, 40);
            IFigure clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();

            figure       = new Circle(30);
            clonedFigure = figure.Clone();
            figure.GetInfo();
            clonedFigure.GetInfo();

            //-Builder-
            // содаем объект пекаря
            Baker baker = new Baker();
            // создаем билдер для ржаного хлеба
            BreadBuilder builder = new RyeBreadBuilder();
            // выпекаем
            Bread ryeBread = baker.Bake(builder);
            Console.WriteLine(ryeBread.ToString());
            // оздаем билдер для пшеничного хлеба
            builder = new WheatBreadBuilder();
            Bread wheatBread = baker.Bake(builder);
            Console.WriteLine(wheatBread.ToString());
            #endregion

            #region Behavioral
            //-Strategy-
            Car auto = new Car(4, "Volvo", new PetrolMove());
            auto.Move();
            auto.Movable = new ElectricMove();
            auto.Move();


            //-Observer-
            Stock  stock  = new Stock();
            Bank   bank   = new Bank("ЮнитБанк", stock);
            Broker broker = new Broker("Иван Иваныч", stock);
            // имитация торгов
            stock.Market();
            // брокер прекращает наблюдать за торгами
            broker.StopTrade();
            // имитация торгов
            stock.Market();


            //-Strategy-
            Pult pult = new Pult();
            TV   tv   = new TV();
            pult.SetCommand(new TVOnCommand(tv));
            pult.PressButton();
            pult.PressUndo();

            Microwave microwave = new Microwave();
            // 5000 - время нагрева пищи
            pult.SetCommand(new MicrowaveCommand(microwave, 5000));
            pult.PressButton();


            //-Iterator-
            Library library = new Library();
            Reader  reader  = new Reader();
            reader.SeeBooks(library);


            //-State-
            Water water = new Water(new LiquidWaterState());
            water.Heat();
            water.Frost();
            water.Frost();


            //-ChainOfResponsibility-
            Handler h1 = new ConcreteHandler1();
            Handler h2 = new ConcreteHandler2();
            h1.Successor = h2;
            h1.HandleRequest(2);


            //-Interpreter-
            Context context = new Context();
            // определяем набор переменных
            int x = 5;
            int y = 8;
            int z = 2;
            // добавляем переменные в контекст
            context.SetVariable("x", x);
            context.SetVariable("y", y);
            context.SetVariable("z", z);
            // создаем объект для вычисления выражения x + y - z
            IExpression expression = new SubtractExpression(
                new AddExpression(
                    new NumberExpression("x"), new NumberExpression("y")
                    ),
                new NumberExpression("z")
                );
            int result = expression.Interpret(context);
            Console.WriteLine("результат: {0}", result);


            //-Mediator-
            ManagerMediator mediator   = new ManagerMediator();
            Colleague       customer   = new CustomerColleague(mediator);
            Colleague       programmer = new ProgrammerColleague(mediator);
            Colleague       tester     = new TesterColleague(mediator);
            mediator.Customer   = customer;
            mediator.Programmer = programmer;
            mediator.Tester     = tester;
            customer.Send("Есть заказ, надо сделать программу");
            programmer.Send("Программа готова, надо протестировать");
            tester.Send("Программа протестирована и готова к продаже");


            //-Memento-
            GofPatterns.Behavioral.Hero hero = new GofPatterns.Behavioral.Hero();
            hero.Shoot();                        // делаем выстрел, осталось 9 патронов
            GameHistory game = new GameHistory();
            game.History.Push(hero.SaveState()); // сохраняем игру
            hero.Shoot();                        //делаем выстрел, осталось 8 патронов
            hero.RestoreState(game.History.Pop());
            hero.Shoot();                        //делаем выстрел, осталось 8 патронов


            //-Visitor-
            var structure = new Bank1();
            structure.Add(new Person {
                Name = "Иван Алексеев", Number = "82184931"
            });
            structure.Add(new Company {
                Name = "Microsoft", RegNumber = "ewuir32141324", Number = "3424131445"
            });
            structure.Accept(new HtmlVisitor());
            structure.Accept(new XmlVisitor());
            #endregion

            #region Structural
            //-Decorator-
            Pizza pizza1 = new ItalianPizza();
            pizza1 = new TomatoPizza(pizza1); // итальянская пицца с томатами
            Console.WriteLine("Название: {0}", pizza1.Name);
            Console.WriteLine("Цена: {0}", pizza1.GetCost());

            Pizza pizza2 = new ItalianPizza();
            pizza2 = new CheesePizza(pizza2);// итальянская пиццы с сыром
            Console.WriteLine("Название: {0}", pizza2.Name);
            Console.WriteLine("Цена: {0}", pizza2.GetCost());

            Pizza pizza3 = new BulgerianPizza();
            pizza3 = new TomatoPizza(pizza3);
            pizza3 = new CheesePizza(pizza3);// болгарская пиццы с томатами и сыром
            Console.WriteLine("Название: {0}", pizza3.Name);
            Console.WriteLine("Цена: {0}", pizza3.GetCost());


            //-Adapter-
            // путешественник
            Driver driver = new Driver();
            // машина
            Auto auto1 = new Auto();
            // отправляемся в путешествие
            driver.Travel(auto1);
            // встретились пески, надо использовать верблюда
            Camel camel = new Camel();
            // используем адаптер
            ITransport camelTransport = new CamelToTransportAdapter(camel);
            // продолжаем путь по пескам пустыни
            driver.Travel(camelTransport);


            //-Facade-
            TextEditor         textEditor  = new TextEditor();
            Compiller          compiller   = new Compiller();
            CLR                clr         = new CLR();
            VisualStudioFacade ide         = new VisualStudioFacade(textEditor, compiller, clr);
            Programmer         programmer1 = new Programmer();
            programmer1.CreateApplication(ide);


            //-Composite-
            Component fileSystem = new Directory("Файловая система");
            // определяем новый диск
            Component diskC = new Directory("Диск С");
            // новые файлы
            Component pngFile  = new File("12345.png");
            Component docxFile = new File("Document.docx");
            // добавляем файлы на диск С
            diskC.Add(pngFile);
            diskC.Add(docxFile);
            // добавляем диск С в файловую систему
            fileSystem.Add(diskC);
            // выводим все данные
            fileSystem.Print();
            Console.WriteLine();
            // удаляем с диска С файл
            diskC.Remove(pngFile);
            // создаем новую папку
            Component docsFolder = new Directory("Мои Документы");
            // добавляем в нее файлы
            Component txtFile = new File("readme.txt");
            Component csFile  = new File("Program.cs");
            docsFolder.Add(txtFile);
            docsFolder.Add(csFile);
            diskC.Add(docsFolder);
            fileSystem.Print();


            //-Proxy-
            using (IBook book = new BookStoreProxy())
            {
                // читаем первую страницу
                Page page1 = book.GetPage(1);
                Console.WriteLine(page1.Text);
                // читаем вторую страницу
                Page page2 = book.GetPage(2);
                Console.WriteLine(page2.Text);
                // возвращаемся на первую страницу
                page1 = book.GetPage(1);
                Console.WriteLine(page1.Text);
            }


            //-Bridge-
            // создаем нового программиста, он работает с с++
            Programmer1 freelancer = new FreelanceProgrammer(new CPPLanguage());
            freelancer.DoWork();
            freelancer.EarnMoney();
            // пришел новый заказ, но теперь нужен c#
            freelancer.Language = new CSharpLanguage();
            freelancer.DoWork();
            freelancer.EarnMoney();


            //-Flyweight-
            double longitude = 37.61;
            double latitude  = 55.74;

            HouseFactory houseFactory = new HouseFactory();
            for (int i = 0; i < 5; i++)
            {
                House1 panelHouse = houseFactory.GetHouse("Panel");
                if (panelHouse != null)
                {
                    panelHouse.Build(longitude, latitude);
                }
                longitude += 0.1;
                latitude  += 0.1;
            }

            for (int i = 0; i < 5; i++)
            {
                House1 brickHouse = houseFactory.GetHouse("Brick");
                if (brickHouse != null)
                {
                    brickHouse.Build(longitude, latitude);
                }
                longitude += 0.1;
                latitude  += 0.1;
            }
            #endregion
        }
Exemple #21
0
        public void LoadCommonLanguageRuntime(string RuntimeVersion)
        {
            if (string.IsNullOrEmpty(RuntimeVersion))
            {
                throw new ArgumentNullException("RuntimeVersion");
            }

            this.ThrowIfDisposed();
            this.ThrowIfNoHandle();

            if (this.Clr != null)
            {
                return;
            }

            this.Clr = new CLR();

            this.Clr.pMSCorEE            = this.LoadLibrary("MSCorEE.dll");
            this.Clr.pCorBindToRuntimeEx = this.GetProcAddress(this.Clr.pMSCorEE, "CorBindToRuntimeEx");
            this.Clr.CorBindToRuntimeEx  = this.GetFunction <CLR.CorBindToRuntimeExPrototype>(this.Clr.pCorBindToRuntimeEx);

            uint status = this.Clr.CorBindToRuntimeEx(RuntimeVersion, "wks", 0, CLR.CLSID_CLRRuntimeHost, CLR.IID_ICLRRuntimeHost, out this.Clr.ppClrHost);

            if (status != Win32.ERROR_SUCCESS)
            {
                throw new Win32Exception((int)status);
            }

            this.Clr.pClrHost = this.ReadIntPtr(this.Clr.ppClrHost);

            if (this.Clr.pClrHost == IntPtr.Zero)
            {
                throw new Exception();
            }

            if (this.Is64BitProcess)
            {
                CLR.ICLRRuntimeHostVtblx64 ClrHost = this.ReadStruct <CLR.ICLRRuntimeHostVtblx64>(this.Clr.pClrHost);

                this.Clr.pRelease = new IntPtr(ClrHost.Release);
                this.Clr.pStart   = new IntPtr(ClrHost.Start);
                this.Clr.pStop    = new IntPtr(ClrHost.Stop);
                this.Clr.pExecuteInDefaultAppDomain = new IntPtr(ClrHost.ExecuteInDefaultAppDomain);
            }
            else
            {
                CLR.ICLRRuntimeHostVtblx86 ClrHost = this.ReadStruct <CLR.ICLRRuntimeHostVtblx86>(this.Clr.pClrHost);

                this.Clr.pRelease = new IntPtr(ClrHost.Release);
                this.Clr.pStart   = new IntPtr(ClrHost.Start);
                this.Clr.pStop    = new IntPtr(ClrHost.Stop);
                this.Clr.pExecuteInDefaultAppDomain = new IntPtr(ClrHost.ExecuteInDefaultAppDomain);
            }

            //this.Clr.Release = this.GetFunction<CLR.ICLRRuntimeHostReleasePrototype>(this.Clr.pRelease);
            this.Clr.Release = (This) => this.CallFunctionThreadProc(this.Clr.pRelease, This);
            //this.Clr.Start = this.GetFunction<CLR.ICLRRuntimeHostStartPrototype>(this.Clr.pStart);
            this.Clr.Start = (This) => this.CallFunctionThreadProc(this.Clr.pStart, This);
            //this.Clr.Stop = this.GetFunction<CLR.ICLRRuntimeHostStopPrototype>(this.Clr.pStop);
            this.Clr.Stop = (This) => this.CallFunctionThreadProc(this.Clr.pStop, This);
            this.Clr.ExecuteInDefaultAppDomain = this.GetFunction <CLR.ICLRRuntimeHostExecuteInDefaultAppDomainPrototype>(this.Clr.pExecuteInDefaultAppDomain);

            status = this.Clr.Start(this.Clr.ppClrHost);

            if (status != Win32.ERROR_SUCCESS)
            {
                throw new Win32Exception((int)status);
            }
        }
Exemple #22
0
        private CLR.CLRTypeSpec TypeSpecForArrayIndex(CLR.CLRTypeSpec indexBaseSpec)
        {
            NumericStackType indexNst = StackTypeForTypeSpec(indexBaseSpec);
            CLR.CLRSigType.ElementType indexElementType;

            if (indexNst == NumericStackType.Int32)
                indexElementType = CLR.CLRSigType.ElementType.I4;
            else if (indexNst == NumericStackType.NativeInt)
                indexElementType = CLR.CLRSigType.ElementType.I;    // CLARITYTODO: Test UIntPtr
            else
                throw new ArgumentException("Unusual array index type");

            return m_builder.Assemblies.InternVagueType(new CLR.CLRSigTypeSimple(indexElementType));
        }
 public VisualStudioFacade(TextEditor txEditor, Compiler compiler, CLR clr)
 {
     _textEditor = txEditor;
     _compiler   = compiler;
     _clr        = clr;
 }
Exemple #24
0
 public IDEFacade(TextEditor te, Compiler compil, CLR clr)
 {
     this.textEditor = te;
     this.compiller  = compil;
     this.clr        = clr;
 }
Exemple #25
0
 private static MidInstruction.OpcodeEnum SimpleTranslateInstr(CLR.CIL.HLOpcode opcode)
 {
     switch (opcode)
     {
         case CLR.CIL.HLOpcode.bge:
             return MidInstruction.OpcodeEnum.bge;
         case CLR.CIL.HLOpcode.bgt:
             return MidInstruction.OpcodeEnum.bgt;
         case CLR.CIL.HLOpcode.ble:
             return MidInstruction.OpcodeEnum.ble;
         case CLR.CIL.HLOpcode.blt:
             return MidInstruction.OpcodeEnum.blt;
         case CLR.CIL.HLOpcode.clt:
             return MidInstruction.OpcodeEnum.clt;
         case CLR.CIL.HLOpcode.add:
             return MidInstruction.OpcodeEnum.add;
         case CLR.CIL.HLOpcode.sub:
             return MidInstruction.OpcodeEnum.sub;
         case CLR.CIL.HLOpcode.mul:
             return MidInstruction.OpcodeEnum.mul;
         case CLR.CIL.HLOpcode.div:
             return MidInstruction.OpcodeEnum.div;
         case CLR.CIL.HLOpcode.rem:
             return MidInstruction.OpcodeEnum.rem;
         case CLR.CIL.HLOpcode.and:
             return MidInstruction.OpcodeEnum.and;
         case CLR.CIL.HLOpcode.or:
             return MidInstruction.OpcodeEnum.or;
         case CLR.CIL.HLOpcode.xor:
             return MidInstruction.OpcodeEnum.xor;
         case CLR.CIL.HLOpcode.shl:
             return MidInstruction.OpcodeEnum.shl;
         case CLR.CIL.HLOpcode.shr:
             return MidInstruction.OpcodeEnum.shr;
         case CLR.CIL.HLOpcode.not:
             return MidInstruction.OpcodeEnum.not;
         case CLR.CIL.HLOpcode.neg:
             return MidInstruction.OpcodeEnum.neg;
         default:
             throw new ArgumentException();
     }
 }