예제 #1
0
        public void SetUp()
        {
            _materialCache = new MaterialCache();
            _parentMtl     = _materialCache.Add("testmtl1");
            _childMtl      = _materialCache.Add("testmtl2");

            _epicModel = new EpicModel();

            _parentCuboid            = Cuboid.CreateCuboid();
            _parentCuboid.Size       = new Vector3(2, 2, 2);
            _parentCuboid.Rotation   = new Vector3(0, 0, -(float)Math.PI / 4.0f);
            _parentCuboid.MaterialId = _parentMtl.Id;

            _connector          = _parentCuboid.AddAnchor("Connector");
            _connector.Position = new Vector3(1, 1, 0);

            _childCuboid            = Cuboid.CreateCuboid();
            _childCuboid.Position   = new Vector3(-1, -1, 0);
            _childCuboid.Rotation   = new Vector3(0, 0, -(float)Math.PI / 2.0f);
            _childCuboid.MaterialId = _childMtl.Id;


            _epicModel.ModelParts.Add(_parentCuboid);
            _childCuboid.Pivot.SetParent(_connector);

            _compiler      = new EpicModelCompiler(_epicModel);
            _compiledModel = _compiler.Compile();

            _modelInstance = new ModelInstance(_compiledModel, _materialCache);

            _modelInstance.Update(1 / 24.0f);
        }
예제 #2
0
        public IExecutionEngine GetExecutor(CompiledModel compiledModel, IILOperationSet ilOperationSet)
        {
            _typeLoader.LoadGlobalMethods(compiledModel.Methods.Values.ToList());
            IExecutionEngine executor = new ExecutionEngine(compiledModel, _gcHeap, _typesHeap, _typeLoader, new CallStack(Int16.MaxValue), ilOperationSet);

            return(executor);
        }
예제 #3
0
        public override void SetUp()
        {
            base.SetUp();

            Compiler      = new EpicModelCompiler(Model);
            CompiledModel = Compiler.Compile();
        }
예제 #4
0
        public void SimpleTryBlockWithinOneMethodWithTwoCatchHandlers()
        {
            //Arrange
            ITest test = new CorrectOrderCheck();

            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Nop, "1. Just before try start").Data(1),
                //----------try begin-------------
                new ILInstruction(ByteCode.Nop, "2. At the try first instruction start").AddLabel("TryBeg").Data(2),
                new ILInstruction(ByteCode.Nop, "3. Just before throw").Data(3),
                new ILInstruction(ByteCode.Newobj, TempTypeLocator.InvalidOperationExceptionDesc.Methods[0].Metadata /*ctor*/),
                new ILInstruction(ByteCode.Throw),
                new ILInstruction(ByteCode.Nop, "Just after throw"),
                new ILInstruction(ByteCode.Nop, "Just before try leave instruction"),
                new ILInstruction(ByteCode.Leave, new Label("TryLeaveDest")).AddLabel("TryEnd"),
                //----------try end-------------
                new ILInstruction(ByteCode.Nop, "Between try and catch"),
                //----------catch1 begin-------------
                new ILInstruction(ByteCode.Nop, "4. At the catch1 start").AddLabel("Catch1Beg").Data(4),
                new ILInstruction(ByteCode.Pop),
                new ILInstruction(ByteCode.Nop, "5. Just before catch1 leave instruction").Data(5),
                new ILInstruction(ByteCode.Leave, new Label("CatchLeaveDest")).AddLabel("Catch1End"),
                //----------catch1 end-------------

                //----------catch2 begin-------------
                new ILInstruction(ByteCode.Pop).AddLabel("Catch2Beg"),
                new ILInstruction(ByteCode.Nop, "At the catch2 start"),
                new ILInstruction(ByteCode.Nop, "Just before catch2 leave instruction"),
                new ILInstruction(ByteCode.Leave, new Label("CatchLeaveDest")).AddLabel("Catch2End"),
                //----------catch2 end-------------
                new ILInstruction(ByteCode.Nop, "Instruction where try leave points").AddLabel("TryLeaveDest"),
                new ILInstruction(ByteCode.Nop, "6(end). Instruction where catch leave points").AddLabel("CatchLeaveDest").Data(6),
                new ILInstruction(ByteCode.Ret)
            });

            mainMethod.EHTable.AddCatchHandler("TryBeg", "TryEnd", new ClassToken("System.InvalidOperationException", false), "Catch1Beg", "Catch1End");
            mainMethod.EHTable.AddCatchHandler("TryBeg", "TryEnd", new ClassToken("System.Exception", false), "Catch2Beg", "Catch2End");


            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);

            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.ObjectDesc);
            domainModel.LoadType(TempTypeLocator.ExceptionDesc);
            domainModel.LoadType(TempTypeLocator.InvalidOperationExceptionDesc);

            var executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
            Assert.IsTrue(test.Success());
        }
예제 #5
0
 public DQNTrainer(CompiledModel model, int memoryCapacity = 100000)
 {
     DiscountFactorGrowSteps = 100000;
     LearningRateDecaySteps  = 500000;
     ReplayMemory            = new FixedSizeList <Tuple <float[], int, float, float[]> >(memoryCapacity, false);
     TargetModel             = model;
     Reset();
 }
 private void AddAssemblyClasses(LoadedClasses classes, CompiledModel compiledModel)
 {
     InitializersData.Clear();
     foreach (KeyValuePair <ClassFile, FileContents> pair in classes.Files)
     {
         AddType(pair, compiledModel);
     }
 }
        public void Update(LoadedClasses classes)
        {
            classes.SaveFilesContents(null);

            CompiledModel = ComileAssembly(classes);

            AddAssemblyClasses(classes, CompiledModel);
        }
예제 #8
0
        public void SaveAndLoad()
        {
            Logger.Add(new TraceLogger {
                LoggerLevel = LoggerLevel.Trace
            });

            _model = new EpicModel();
            var cuboid = Cuboid.CreateCuboid();

            cuboid.MaterialId = 1;
            cuboid.Name       = "Cuboid1";
            cuboid.AddAnchor("a1");
            cuboid.AddAnchor("a2");

            var cuboid2 = Cuboid.CreateCuboid();

            cuboid2.MaterialId = 1;
            cuboid2.Name       = "Cuboid2";
            var a3 = cuboid2.AddAnchor("a3");

            var a4 = cuboid2.AddAnchor("a4");

            a4.Position = new Vector3(0.5f, 0.0f, 0.0f);

            cuboid.Pivot.SetParent(a3);

            _model.ModelParts.Add(cuboid);
            _model.ModelParts.Add(cuboid2);

            var cuboid3 = Cuboid.CreateCuboid();

            cuboid3.MaterialId = 0;
            _model.ModelParts.Add(cuboid3);

            var animation = _model.GetAnimation(AnimationType.Drop, true);

            animation.AddFrame().Time = 0.0f;
            animation.AddFrame().Time = 0.265f;
            animation.AddFrame().Time = 0.384f;

            var animation2 = _model.GetAnimation(AnimationType.Death3, true);

            animation2.AddFrame().Time = 0.0f;

            cuboid2.Rotation = new Vector3(0.0f, 0.0f, (float)(Math.PI / 2.0f));
            cuboid2.Position = new Vector3(-1f, -1f, 0);

            var frame2 = animation2.AddFrame();

            frame2.LoadFromCurrentModelState(_model);
            frame2.Time = 0.519f;

            cuboid2.Rotation = new Vector3();
            cuboid2.Position = new Vector3();

            _compiler      = new EpicModelCompiler(_model);
            _compiledModel = _compiler.Compile();
        }
        private void AddType(KeyValuePair <ClassFile, FileContents> pair,
                             CompiledModel compiledModel)
        {
            string             typeName = pair.Key.TypeName;
            Type               userType = GetType(compiledModel, typeName);
            InitializationData data     = new InitializationData(userType);

            InitializersData.Add(typeName, data);
        }
예제 #10
0
        public void TestCompileOneType()
        {
            TypeCompiler compiler = new TypeCompiler();

            CompiledModel oneType = compiler.Compile(new [] { testClassContent });
            Type          type    = oneType.GetType(TestClass);

            Assert.AreEqual(type.Name, TestClass);
        }
예제 #11
0
        public void SimpleInstructions()
        {
            //Arrange
            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddArguments(new MethodArgDescription[]
            {
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldc_I4, 2),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Ldc_I4, 4),
                new ILInstruction(ByteCode.Stloc, 1),
                new ILInstruction(ByteCode.Ldloc, 1),
                new ILInstruction(ByteCode.Ldloc, 0),
                new ILInstruction(ByteCode.Mul),
                new ILInstruction(ByteCode.Ldloc, 1),
                new ILInstruction(ByteCode.Mul)
            });



            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);

            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.Int32Desc);
            IExecutionEngine executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
        }
        private void LoadAssembly_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            DevExpress.Xpo.Metadata.XPDictionary dict = new DevExpress.Xpo.Metadata.ReflectionDictionary();
            string assemblyFile = GetAssemblyPath();

            if (string.IsNullOrEmpty(assemblyFile))
            {
                return;
            }

            var asm = Assembly.LoadFrom(assemblyFile);

            var types = asm.GetExportedTypes();



            CompiledModel compiledModel = (CompiledModel)e.CurrentObject;

            compiledModel.Assembly = assemblyFile;
            compiledModel.Name     = Path.GetFileName(assemblyFile);

            //System.Object,DevExpress.Xpo.IXPObject,DevExpress.Xpo.IXPSimpleObject,DevExpress.Xpo.Helpers.IXPClassInfoAndSessionProvider,DevExpress.Xpo.Helpers.IXPClassInfoProvider,DevExpress.Xpo.Metadata.Helpers.IXPDictionaryProvider,DevExpress.Xpo.Helpers.ISessionProvider,DevExpress.Xpo.Helpers.IObjectLayerProvider,DevExpress.Xpo.Helpers.IDataLayerProvider,DevExpress.Xpo.IXPCustomPropertyStore,DevExpress.Xpo.IXPModificationsStore,DevExpress.Xpo.IXPInvalidateableObject,DevExpress.Xpo.IXPReceiveOnChangedFromDelayedProperty,DevExpress.Xpo.IXPReceiveOnChangedFromArbitrarySource,System.ComponentModel.INotifyPropertyChanged,DevExpress.Xpo.Helpers.IXPImmutableHashCode,System.ComponentModel.IEditableObject,System.ComponentModel.ICustomTypeDescriptor,System.IComparable,DevExpress.Xpo.IXPReceiveOnChangedFromXPPropertyDescriptor,DevExpress.Xpo.XPObject,DevExpress.Xpo.XPCustomObject,DevExpress.Xpo.XPBaseObject,DevExpress.Xpo.PersistentBase,System.Object
            var AllXpoBases = "System.Object,DevExpress.Xpo.IXPObject,DevExpress.Xpo.IXPSimpleObject,DevExpress.Xpo.Helpers.IXPClassInfoAndSessionProvider,DevExpress.Xpo.Helpers.IXPClassInfoProvider,DevExpress.Xpo.Metadata.Helpers.IXPDictionaryProvider,DevExpress.Xpo.Helpers.ISessionProvider,DevExpress.Xpo.Helpers.IObjectLayerProvider,DevExpress.Xpo.Helpers.IDataLayerProvider,DevExpress.Xpo.IXPCustomPropertyStore,DevExpress.Xpo.IXPModificationsStore,DevExpress.Xpo.IXPInvalidateableObject,DevExpress.Xpo.IXPReceiveOnChangedFromDelayedProperty,DevExpress.Xpo.IXPReceiveOnChangedFromArbitrarySource,System.ComponentModel.INotifyPropertyChanged,DevExpress.Xpo.Helpers.IXPImmutableHashCode,System.ComponentModel.IEditableObject,System.ComponentModel.ICustomTypeDescriptor,System.IComparable,DevExpress.Xpo.IXPReceiveOnChangedFromXPPropertyDescriptor,DevExpress.Xpo.XPObject,DevExpress.Xpo.XPCustomObject,DevExpress.Xpo.XPBaseObject,DevExpress.Xpo.PersistentBase,System.Object";

            var         AllXpoBasesList = AllXpoBases.Split(',').ToList();
            var         GetTypes        = asm.GetTypes();
            List <Type> AllTypes        = new List <Type>();

            foreach (Type type in GetTypes)
            {
                var Parents    = type.GetParentTypes();
                var matches    = Parents.Where(bt => AllXpoBases.Contains(bt.FullName));
                int MatchCount = matches.Count();
                //All types should have at least 1 match that is the object base object
                Debug.WriteLine(MatchCount);
                if (MatchCount > 1)
                {
                    //AllTypes.Add(type);


                    var Found = compiledModel.CompiledModelClasses.FirstOrDefault(mc => mc.Name == type.Name);
                    if (ReferenceEquals(Found, null))
                    {
                        Found               = this.ObjectSpace.CreateObject <CompiledModelClass>();
                        Found.Name          = type.Name;
                        Found.CompiledModel = compiledModel;
                        Found.FullType      = type.FullName;
                    }

                    if (this.View.ObjectSpace.IsModified)
                    {
                        this.View.ObjectSpace.CommitChanges();
                    }
                }
            }
        }
예제 #13
0
        public CompiledModel Compile()
        {
            _compiledModel = new CompiledModel(_epicModel.Name);

            LoadModelStructure();
            LoadAnchors();
            LoadModelData();
            CalculateAnimations();

            return _compiledModel;
        }
예제 #14
0
        public override void SetUp()
        {
            base.SetUp();

            Compiler      = new EpicModelCompiler(Model);
            CompiledModel = Compiler.Compile();

            MaterialCache = new MaterialCache();
            MaterialCache.Add("example_material");
            ModelInstance = new ModelInstance(CompiledModel, MaterialCache);
        }
 private static Type GetType(CompiledModel compiledModel, string typeName)
 {
     try
     {
         return(compiledModel.GetType(typeName));
     }
     catch (InvalidOperationException)
     {
         throw new InitializationException(
                   "Error: Not found one of the types or names of classes are't same as file names without extension.");
     }
 }
예제 #16
0
        public void Compile()
        {
            _epicModel = new Psy.Core.EpicModel.EpicModel();

            var cuboid = Cuboid.CreateCuboid();

            cuboid.Size = new Vector3(1.0f, 1.0f, 1.0f);

            _epicModel.ModelParts.Add(cuboid);

            _compiler      = new EpicModelCompiler(_epicModel);
            _compiledModel = _compiler.Compile();
        }
예제 #17
0
        public void TestCompileTwoTypes()
        {
            TypeCompiler compiler = new TypeCompiler();

            CompiledModel twoTypes = compiler.Compile(
                new []
            {
                testClassContent,
                usingTestClassContent
            });
            Type type = twoTypes.GetType(UsingTestClass);

            Assert.AreEqual(type.Name, UsingTestClass);
        }
예제 #18
0
        public void TestCompileWithGivenTypes()
        {
            TypeCompiler compiler = new TypeCompiler();

            compiler.AddGivenTypes(
                new [] { testClassContent });

            CompiledModel oneType = compiler.Compile(
                new[] { usingTestClassContent });

            Type type = oneType.GetType(UsingTestClass);

            Assert.AreEqual(type.Name, UsingTestClass);
        }
예제 #19
0
        public void SetUp()
        {
            _materialCache = new MaterialCache();
            var testmtl = _materialCache.Add("testmtl");

            _epicModel = new Psy.Core.EpicModel.EpicModel();

            var cuboid = Cuboid.CreateCuboid();

            cuboid.Size       = new Vector3(1.0f, 1.0f, 1.0f);
            cuboid.MaterialId = testmtl.Id;

            _epicModel.ModelParts.Add(cuboid);

            _compiler      = new EpicModelCompiler(_epicModel);
            _compiledModel = _compiler.Compile();

            _modelInstance = new ModelInstance(_compiledModel, _materialCache);

            _modelInstance.Update(1 / 24.0f);
        }
예제 #20
0
        public void DomainModelBaseBehavior()
        {
            //Arrange
            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddReturnType(TempTypeLocator.Int32Desc.Metadata)
                                    .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldc_I4, 2),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Ldloc, 0),
                new ILInstruction(ByteCode.Box),
                new ILInstruction(ByteCode.Ret),
            });

            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);


            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.Int32Desc);
            var executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
        }
예제 #21
0
        protected IExecutionEngine GetExecutionEngineForGlobalEntryPoint(params MethodDesc[] globalMethods)
        {
            CompiledModel compiledModel = new CompiledModel();

            foreach (MethodDesc method in globalMethods)
            {
                compiledModel.AddMethod(method);
            }

            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.Int32Desc);
            domainModel.LoadType(TempTypeLocator.UInt32Desc);
            domainModel.LoadType(TempTypeLocator.BooleanDesc);
            domainModel.LoadType(TempTypeLocator.Int16Desc);
            domainModel.LoadType(TempTypeLocator.UInt16Desc);
            domainModel.LoadType(TempTypeLocator.Int64Desc);
            domainModel.LoadType(TempTypeLocator.UInt64Desc);
            domainModel.LoadType(TempTypeLocator.ByteDesc);
            domainModel.LoadType(TempTypeLocator.SByteDesc);
            var executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            return(executor);
        }
예제 #22
0
 public DDQNTrainer(CompiledModel model, int memoryCapacity = 100000) : base(model, memoryCapacity)
 {
 }
예제 #23
0
        public void TryFinallyInsideAnotherTryFinallyBlock()
        {
            ITest test = new CorrectOrderCheck();
            //Arrange
            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddCallback(test)
                                    .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddArguments(new MethodArgDescription[]
            {
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Nop, "1. Outer try start").Data(1),                       //0
                new ILInstruction(ByteCode.Nop, "2. Outer try leave instruction").Data(2),
                new ILInstruction(ByteCode.Leave, 13),                                               //2

                //----------outer finally begin-------------
                new ILInstruction(ByteCode.Nop, "3. Outer finally start").Data(3),               //3

                new ILInstruction(ByteCode.Nop, "4. Inner try first instruction start").Data(4), //4
                new ILInstruction(ByteCode.Nop, "5. Just before inner try leave instruction").Data(5),
                new ILInstruction(ByteCode.Leave, 11),                                           //6

                new ILInstruction(ByteCode.Nop, "Between inner try and inner finally"),

                new ILInstruction(ByteCode.Nop, "6. At the inner finally start").Data(6),               //8
                new ILInstruction(ByteCode.Nop, "7. Just before inner endfinally instruction").Data(7),
                new ILInstruction(ByteCode.Endfinally),                                                 //10

                new ILInstruction(ByteCode.Nop, "8. Just before outer endfinally instruction").Data(8), //11
                new ILInstruction(ByteCode.Endfinally),                                                 //12
                //----------outer finally end-------------

                new ILInstruction(ByteCode.Nop, "9(end). instruction where outer try's leave points").Data(9),                                //13
                new ILInstruction(ByteCode.Ret)
            });

            mainMethod.EHTable.AddFinallyHandler(4, 6, 8, 10);
            mainMethod.EHTable.AddFinallyHandler(0, 2, 3, 12);

            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);

            DomainModel      domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());
            IExecutionEngine executor    = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
            Assert.IsTrue(test.Success());
        }
예제 #24
0
        public void CreateSimpleObjectWithCtorAndCallItsMethod()
        {
            //Arrange
            var myObj = new TypeDesc()
            {
                Name        = "MyNamespace.MyObject",
                IsPrimitive = false,
                IsValueType = false,
                BaseClass   = TempTypeLocator.ObjectDesc
            };

            myObj.Methods.Add(new MethodDesc(".ctor()", 1)
                              .BelongsTo(myObj)
                              .AddPropertiesFlag(MethodOtherProps.SpecialName)
                              .AddReturnType(TempTypeLocator.Int32Desc.Metadata)
                              .AddArguments(new MethodArgDescription[]
            {
                new MethodArgDescription()
                {
                    TypeToken = myObj.Metadata, SType = ESSlotType.HORef                                                   /*this*/
                },
            })
                              .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldarg, 0),
                new ILInstruction(ByteCode.Ret)
            }));

            myObj.Methods.Add(new MethodDesc("Int32 ManipulateNewObj()", 1)
                              .BelongsTo(myObj)
                              .AddReturnType(TempTypeLocator.Int32Desc.Metadata)
                              .AddArguments(new MethodArgDescription[]
            {
                new MethodArgDescription()
                {
                    TypeToken = myObj.Metadata, SType = ESSlotType.HORef                                                   /*this*/
                },
            })
                              .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = myObj.Metadata
                },
            })
                              .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldarg, 0),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Ldloc, 0),
                new ILInstruction(ByteCode.Ret)
            }));


            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = myObj.Metadata, SType = ESSlotType.HORef
                },
            })
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Nop),
                new ILInstruction(ByteCode.Newobj, myObj.Methods[0].Metadata /*.ctor*/),
                new ILInstruction(ByteCode.Callvirt, myObj.Methods[1].Metadata /*ManipulateNewObj*/),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Ret),
            });

            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);


            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.Int32Desc);
            domainModel.LoadType(myObj);
            var executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
        }
예제 #25
0
        public void ThreeMethodsWithExThrowingAndFinalliesAndCatches()
        {
            //Arrange
            ITest test = new CorrectOrderCheck();

            MethodDesc thirdMethod = new MethodDesc("ThirdMethod", 3)
                                     .AddCallback(test)
                                     .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                     .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Nop, "1. Just before outer tryfin try start").Data(5),
                //----------outer tryfin try begin-------------
                new ILInstruction(ByteCode.Nop, "2. Outer tryfin try first instruction").AddLabel("OuterTryBeg").Data(6),

                //----------mid try begin-------------
                new ILInstruction(ByteCode.Nop, "3. At the mid try-catch try first instruction").AddLabel("MidTryBeg").Data(7),

                //----------inner try begin-------------
                new ILInstruction(ByteCode.Nop, "4. At the inner try first instruction").AddLabel("InnerTryBeg").Data(8),
                new ILInstruction(ByteCode.Nop, "5. Just before throw").Data(9),
                new ILInstruction(ByteCode.Newobj, TempTypeLocator.ExceptionDesc.Methods[0].Metadata /*ctor*/),
                new ILInstruction(ByteCode.Throw),
                new ILInstruction(ByteCode.Nop, "Just after throw"),
                new ILInstruction(ByteCode.Leave, new Label("InnerLeaveTarget")).AddLabel("InnerTryEnd"),
                //----------inner try end-------------
                new ILInstruction(ByteCode.Nop, "Between inner try and inner finally"),
                //----------inner finally begin-------------
                new ILInstruction(ByteCode.Nop, "6. Inner finally start").AddLabel("InnerFinBeg").Data(10),
                new ILInstruction(ByteCode.Nop, "7. Just before inner Endfinally").Data(11),
                new ILInstruction(ByteCode.Endfinally).AddLabel("InnerFinEnd"),
                //----------inner finally end-------------

                new ILInstruction(ByteCode.Nop).AddLabel("InnerLeaveTarget"),
                new ILInstruction(ByteCode.Leave, new Label("AfterMidBlock")).AddLabel("MidTryEnd"),
                //----------mid try end-------------

                //----------mid catch begin-------------
                new ILInstruction(ByteCode.Nop, "At the mid catch start").AddLabel("MidCatchBeg"),
                new ILInstruction(ByteCode.Nop, "Just before mid catch leave instruction"),
                new ILInstruction(ByteCode.Leave, new Label("AfterMidBlock")).AddLabel("MidCatchEnd"),
                //----------mid catch end-------------

                new ILInstruction(ByteCode.Nop, "Just before outer try leave instruction").AddLabel("AfterMidBlock"),
                new ILInstruction(ByteCode.Leave, new Label("OuterTryLeaveDest")).AddLabel("OuterTryEnd"),
                //----------outer try end-------------

                //----------outer finally begin-------------
                new ILInstruction(ByteCode.Nop, "8. At the outer finally start").AddLabel("OuterFinBeg").Data(12),
                new ILInstruction(ByteCode.Nop, "9. Just before Endfinally").Data(13),
                new ILInstruction(ByteCode.Endfinally).AddLabel("OuterFinEnd"),
                //----------outer finally end-------------

                new ILInstruction(ByteCode.Ret).AddLabel("OuterTryLeaveDest")
            });

            thirdMethod.EHTable.AddFinallyHandler("InnerTryBeg", "InnerTryEnd", "InnerFinBeg", "InnerFinEnd");
            thirdMethod.EHTable.AddCatchHandler("MidTryBeg", "MidTryEnd", TempTypeLocator.InvalidOperationExceptionDesc.Metadata, "MidCatchBeg", "MidCatchEnd");
            thirdMethod.EHTable.AddFinallyHandler("OuterTryBeg", "OuterTryEnd", "OuterFinBeg", "OuterFinEnd");



            MethodDesc secondMethod = new MethodDesc("SecondMethod", 3)
                                      .AddCallback(test)
                                      .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                      .AddInstructions(new ILInstruction[]
            {
                //----------outer try begin-------------
                new ILInstruction(ByteCode.Nop, "Outer try first instruction").AddLabel("OuterTryBeg").Data(3),

                //----------inner try begin-------------
                new ILInstruction(ByteCode.Nop, "At the inner try first instruction").AddLabel("InnerTryBeg").Data(4),

                new ILInstruction(ByteCode.Call, thirdMethod.Metadata),

                new ILInstruction(ByteCode.Leave, new Label("AfterMidBlock")).AddLabel("InnerTryEnd"),
                //----------inner try end-------------

                //----------inner finally begin-------------
                new ILInstruction(ByteCode.Nop, "Inner finally start").AddLabel("InnerFinBeg").Data(14),
                new ILInstruction(ByteCode.Nop, "Just before inner Endfinally").Data(15),
                new ILInstruction(ByteCode.Endfinally).AddLabel("InnerFinEnd"),
                //----------inner finally end-------------

                new ILInstruction(ByteCode.Nop, "Just before outer try leave instruction").AddLabel("AfterMidBlock"),
                new ILInstruction(ByteCode.Leave, new Label("OuterTryLeaveDest")).AddLabel("OuterTryEnd"),
                //----------outer try end-------------

                //----------outer finally begin-------------
                new ILInstruction(ByteCode.Nop, "At the outer finally start").AddLabel("OuterFinBeg").Data(16),
                new ILInstruction(ByteCode.Nop, "Just before Endfinally").Data(17),
                new ILInstruction(ByteCode.Endfinally).AddLabel("OuterFinEnd"),
                //----------outer finally end-------------

                new ILInstruction(ByteCode.Ret).AddLabel("OuterTryLeaveDest")
            });

            secondMethod.EHTable.AddFinallyHandler("InnerTryBeg", "InnerTryEnd", "InnerFinBeg", "InnerFinEnd");
            secondMethod.EHTable.AddFinallyHandler("OuterTryBeg", "OuterTryEnd", "OuterFinBeg", "OuterFinEnd");


            MethodDesc firstMethod = new MethodDesc("FirstMethod", 3)
                                     .EntryPoint()
                                     .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                     .AddCallback(test)
                                     .AddLocals(new LocalVarDescription[] {
                new LocalVarDescription()
                {
                    SType     = ESSlotType.HORef,
                    TypeToken = TempTypeLocator.ExceptionDesc.Metadata
                }
            })
                                     .AddInstructions(new ILInstruction[]
            {
                //----------outer try begin-------------
                new ILInstruction(ByteCode.Nop, "Outer try first instruction").AddLabel("OuterTryBeg").Data(1),

                //----------inner try begin-------------
                new ILInstruction(ByteCode.Nop, "At the inner try first instruction").AddLabel("InnerTryBeg").Data(2),

                new ILInstruction(ByteCode.Call, secondMethod.Metadata),

                new ILInstruction(ByteCode.Leave, new Label("AfterMidBlock")).AddLabel("InnerTryEnd"),
                //----------inner try end---------------

                //----------inner finally begin-----------
                new ILInstruction(ByteCode.Nop, "Inner finally start").AddLabel("InnerFinBeg").Data(18),
                new ILInstruction(ByteCode.Nop, "Just before inner Endfinally").Data(19),
                new ILInstruction(ByteCode.Endfinally).AddLabel("InnerFinEnd"),
                //----------inner finally end-------------

                new ILInstruction(ByteCode.Nop, "Just before outer try leave instruction").AddLabel("AfterMidBlock"),
                new ILInstruction(ByteCode.Leave, new Label("OuterTryLeaveDest")).AddLabel("OuterTryEnd"),
                //----------outer try end-------------

                //----------outer catch begin-------------
                new ILInstruction(ByteCode.Nop, "At the outer catch start").AddLabel("OuterCatchBeg").Data(20),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Nop, "Just before outer catch leave").Data(21),
                new ILInstruction(ByteCode.Leave, new Label("OuterTryLeaveDest")).AddLabel("OuterCatchEnd"),
                //----------outer catch end-------------

                new ILInstruction(ByteCode.Ret).AddLabel("OuterTryLeaveDest").Data(22)
            });

            firstMethod.EHTable.AddFinallyHandler("InnerTryBeg", "InnerTryEnd", "InnerFinBeg", "InnerFinEnd");
            firstMethod.EHTable.AddCatchHandler("OuterTryBeg", "OuterTryEnd", TempTypeLocator.ExceptionDesc.Metadata, "OuterCatchBeg", "OuterCatchEnd");



            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(firstMethod)
                                          .AddMethod(secondMethod)
                                          .AddMethod(thirdMethod);


            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.ObjectDesc);
            domainModel.LoadType(TempTypeLocator.ExceptionDesc);
            domainModel.LoadType(TempTypeLocator.InvalidOperationExceptionDesc);

            var executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
            Assert.IsTrue(test.Success());
        }
예제 #26
0
        public void SimpleTryCatchAndTryFinallyHandlersWithinOneMethod()
        {
            //Arrange
            ITest test = new CorrectOrderCheck();

            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Nop, "1. Just before outer try start").Data(1),
                //----------outer try begin-------------
                new ILInstruction(ByteCode.Nop, "2. At the outer try first instruction").AddLabel("OuterTryBeg").Data(2),

                //----------inner try begin-------------
                new ILInstruction(ByteCode.Nop, "3. At the inner try first instruction").AddLabel("InnerTryBeg").Data(3),
                new ILInstruction(ByteCode.Nop, "4. Just before throw").Data(4),
                new ILInstruction(ByteCode.Newobj, TempTypeLocator.ExceptionDesc.Methods[0].Metadata /*ctor*/),
                new ILInstruction(ByteCode.Throw),
                new ILInstruction(ByteCode.Nop, "Just after throw"),
                new ILInstruction(ByteCode.Leave, new Label("AfterInnerBlock")).AddLabel("InnerTryEnd"),
                //----------inner try end-------------
                new ILInstruction(ByteCode.Nop, "Between inner try and inner finally"),
                //----------inner finally begin-------------
                new ILInstruction(ByteCode.Nop, "5. Inner finally start").AddLabel("FinBeg").Data(5),
                new ILInstruction(ByteCode.Nop, "6. Just before Endfinally").Data(6),
                new ILInstruction(ByteCode.Endfinally).AddLabel("FinEnd"),
                //----------inner finally end-------------

                new ILInstruction(ByteCode.Nop, "Just before outer try leave instruction").AddLabel("AfterInnerBlock"),
                new ILInstruction(ByteCode.Leave, new Label("TryLeaveDest")).AddLabel("OuterTryEnd"),
                //----------outer try end-------------
                new ILInstruction(ByteCode.Nop, "Between try and catch"),
                //----------outer catch begin-------------
                new ILInstruction(ByteCode.Nop, "7. At the catch start").AddLabel("CatchBeg").Data(7),
                new ILInstruction(ByteCode.Pop),
                new ILInstruction(ByteCode.Nop, "8. Just before catch leave instruction").Data(8),
                new ILInstruction(ByteCode.Leave, new Label("CatchLeaveDest")).AddLabel("CatchEnd"),
                //----------outer catch end-------------

                new ILInstruction(ByteCode.Nop, "Instruction where try leave points").AddLabel("TryLeaveDest"),
                new ILInstruction(ByteCode.Nop, "9(end). Instruction where catch leave points").AddLabel("CatchLeaveDest").Data(9),
                new ILInstruction(ByteCode.Ret)
            });

            mainMethod.EHTable.AddCatchHandler("OuterTryBeg", "OuterTryEnd", TempTypeLocator.ExceptionDesc.Metadata, "CatchBeg", "CatchEnd");
            mainMethod.EHTable.AddFinallyHandler("InnerTryBeg", "InnerTryEnd", "FinBeg", "FinEnd");

            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);

            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.ObjectDesc);
            domainModel.LoadType(TempTypeLocator.ExceptionDesc);
            domainModel.LoadType(TempTypeLocator.InvalidOperationExceptionDesc);

            var executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
            Assert.IsTrue(test.Success());
        }
예제 #27
0
        public void SimpleTryFinally()
        {
            ITest test = new CorrectOrderCheck();
            //Arrange
            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddCallback(test)
                                    .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddArguments(new MethodArgDescription[]
            {
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldc_I4, 2),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Ldc_I4, 4),
                new ILInstruction(ByteCode.Stloc, 1),
                new ILInstruction(ByteCode.Nop, "1. Just before try start").Data(1),
                //----------try begin-------------
                new ILInstruction(ByteCode.Nop, "2. At the try first instruction start").AddLabel("TryBeg").Data(2),                            //5
                new ILInstruction(ByteCode.Ldc_I4, 5),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Nop, "3. Just before leave instruction").Data(3),
                new ILInstruction(ByteCode.Leave, new Label("AfterBlock")).AddLabel("TryEnd"),                               //9                              //9
                //----------try end-------------
                new ILInstruction(ByteCode.Nop, "Between try and finally"),
                //----------finally begin-------------
                new ILInstruction(ByteCode.Nop, "4. At the finally start").AddLabel("FinBeg").Data(4),                                           //11
                new ILInstruction(ByteCode.Ldloc, 1),
                new ILInstruction(ByteCode.Ldloc, 0),
                new ILInstruction(ByteCode.Mul),
                new ILInstruction(ByteCode.Pop),
                new ILInstruction(ByteCode.Nop, "5. Just before endfinally instruction").Data(5),
                new ILInstruction(ByteCode.Endfinally).AddLabel("FinEnd"),                                                            //17
                //----------finally end-------------
                new ILInstruction(ByteCode.Nop, "Just after endfinally instruction"),
                new ILInstruction(ByteCode.Nop, "6(end). instruction where leave points").AddLabel("AfterBlock").Data(6),                                   //19
                new ILInstruction(ByteCode.Ret)
            });

            mainMethod.EHTable.AddFinallyHandler("TryBeg", "TryEnd", "FinBeg", "FinEnd");


            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);

            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.Int32Desc);
            IExecutionEngine executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
            Assert.IsTrue(test.Success());
        }
예제 #28
0
        public void FactorialRecursion()
        {
            //Arrange
            MethodDesc mainMethod = new MethodDesc("Main", 1)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddReturnType(TempTypeLocator.Int32Desc.Metadata)
                                    .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldc_I4, 8),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Ldloc, 0),
                new ILInstruction(ByteCode.Call, new Metadata.MethodToken("", "FactorialMethod", null)),
                new ILInstruction(ByteCode.Stloc, 1),
                new ILInstruction(ByteCode.Ldloc, 1),
                new ILInstruction(ByteCode.Ret)
            });

            MethodDesc factorialMethod = new MethodDesc("FactorialMethod", 3)
                                         .AddReturnType(TempTypeLocator.Int32Desc.Metadata)
                                         .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                         .AddArguments(new MethodArgDescription[]
            {
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                         .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldarg, 0),
                new ILInstruction(ByteCode.Ldc_I4, 2),
                new ILInstruction(ByteCode.Bge, 5),                                      //to the 5th instruction
                new ILInstruction(ByteCode.Ldc_I4, 1),
                new ILInstruction(ByteCode.Ret),
                new ILInstruction(ByteCode.Ldarg, 0),
                new ILInstruction(ByteCode.Ldarg, 0),
                new ILInstruction(ByteCode.Ldc_I4, 1),
                new ILInstruction(ByteCode.Sub),
                new ILInstruction(ByteCode.Call, new Metadata.MethodToken("", "FactorialMethod", null)),
                new ILInstruction(ByteCode.Mul, 2),
                new ILInstruction(ByteCode.Nop, "FactorialMethod before ret"),
                new ILInstruction(ByteCode.Ret)
            });

            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod)
                                          .AddMethod(factorialMethod);

            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.Int32Desc);
            IExecutionEngine executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
            Assert.AreEqual((Int32)executor.EntryPointReturn, 40320);
        }
예제 #29
0
        public void TwoNestedTryFinallyBlocksWithinOneMethod()
        {
            ITest test = new CorrectOrderCheck();
            //Arrange
            MethodDesc mainMethod = new MethodDesc("Main", 3)
                                    .EntryPoint()
                                    .AddInheritanceAttributeFlag(MethodInheritanceAttributes.Global)
                                    .AddCallback(test)
                                    .AddLocals(new LocalVarDescription[]
            {
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new LocalVarDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddArguments(new MethodArgDescription[]
            {
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
                new MethodArgDescription()
                {
                    TypeToken = TempTypeLocator.Int32Desc.Metadata
                },
            })
                                    .AddInstructions(new ILInstruction[]
            {
                new ILInstruction(ByteCode.Ldc_I4, 2),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Ldc_I4, 4),
                new ILInstruction(ByteCode.Stloc, 1),
                new ILInstruction(ByteCode.Nop, "1. Just before outer try start").Data(1),
                //----------outer try begin-------------
                new ILInstruction(ByteCode.Nop, "2. At the outer try first instruction start").AddLabel("OuterTryBeg").Data(2),                            //5
                new ILInstruction(ByteCode.Ldc_I4, 5),
                new ILInstruction(ByteCode.Stloc, 0),
                //----------inner try begin-------------
                new ILInstruction(ByteCode.Nop, "3. At the inner try first instruction start").AddLabel("InnerTryBeg").Data(3),                                //8
                new ILInstruction(ByteCode.Ldc_I4, 5),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Nop, "4. Just before inner leave instruction").Data(4),
                new ILInstruction(ByteCode.Leave, new Label("AfterInnerBlock")).AddLabel("InnerTryEnd"),                                        //12
                //----------inner try end-------------
                new ILInstruction(ByteCode.Nop, "Just after inner try leave instruction"),
                new ILInstruction(ByteCode.Nop, "7. Where inner try's leave points to").AddLabel("AfterInnerBlock").Data(7),                              //14
                new ILInstruction(ByteCode.Ldc_I4, 5),
                new ILInstruction(ByteCode.Stloc, 0),
                new ILInstruction(ByteCode.Nop, "8. Just before outer leave instruction").Data(8),
                new ILInstruction(ByteCode.Leave, new Label("AfterOuterBlock")).AddLabel("OuterTryEnd"),                                       //18
                //----------outer try end-------------
                new ILInstruction(ByteCode.Nop, "Between outer try and finally"),
                //----------outer finally begin-------------
                new ILInstruction(ByteCode.Nop, "9. At the outer finally start").AddLabel("OuterFinBeg").Data(9),                                    //20
                new ILInstruction(ByteCode.Ldloc, 1),
                new ILInstruction(ByteCode.Ldloc, 0),
                new ILInstruction(ByteCode.Mul),
                new ILInstruction(ByteCode.Pop),
                new ILInstruction(ByteCode.Nop, "10. Just before outer endfinally instruction").Data(10),
                new ILInstruction(ByteCode.Endfinally).AddLabel("OuterFinEnd"),                                                            //26
                //----------outer finally end-------------
                new ILInstruction(ByteCode.Nop, "Just after outer endfinally instruction"),
                new ILInstruction(ByteCode.Nop, "11(end). instruction where outer try's leave points").AddLabel("AfterOuterBlock").Data(11),                               //28
                new ILInstruction(ByteCode.Ret),

                //----------inner finally begin-------------
                new ILInstruction(ByteCode.Nop, "5. At the inner finally start").AddLabel("InnerFinBeg").Data(5),                                           //30
                new ILInstruction(ByteCode.Ldloc, 1),
                new ILInstruction(ByteCode.Ldloc, 0),
                new ILInstruction(ByteCode.Mul),
                new ILInstruction(ByteCode.Pop),
                new ILInstruction(ByteCode.Nop, "6. Just before inner endfinally instruction").Data(6),
                new ILInstruction(ByteCode.Endfinally).AddLabel("InnerFinEnd"),                                        //36
                //----------inner finally end-------------
            });

            mainMethod.EHTable.AddFinallyHandler("InnerTryBeg", "InnerTryEnd", "InnerFinBeg", "InnerFinEnd");
            mainMethod.EHTable.AddFinallyHandler("OuterTryBeg", "OuterTryEnd", "OuterFinBeg", "OuterFinEnd");

            CompiledModel compiledModel = new CompiledModel()
                                          .AddMethod(mainMethod);

            DomainModel domainModel = new DomainModel(new GCHeap.Factory(), new TypesHeap.Factory());

            domainModel.LoadType(TempTypeLocator.Int32Desc);
            IExecutionEngine executor = domainModel.GetExecutor(compiledModel, new ILOperationSet());

            //Act
            executor.Start();

            //Assert
            Assert.IsTrue(test.Success());
        }