Beispiel #1
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            this.ownerMethod = ownerMethod;
            this.origOptions = options;

            typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                CanAddGenericTypeVar = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType = ownerType,
                OwnerMethod = ownerMethod,
            };

            this.localsListVM = new IndexObservableCollection<LocalVM>(() => new LocalVM(typeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            this.instructionsListVM = new IndexObservableCollection<InstructionVM>(() => CreateInstructionVM());
            this.exceptionHandlersListVM = new IndexObservableCollection<ExceptionHandlerVM>(() => new ExceptionHandlerVM(typeSigCreatorOptions, new ExceptionHandlerOptions()));
            this.LocalsListVM.UpdateIndexesDelegate = LocalsUpdateIndexes;
            this.InstructionsListVM.UpdateIndexesDelegate = InstructionsUpdateIndexes;
            this.ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            this.InstructionsListVM.CollectionChanged += InstructionsListVM_CollectionChanged;
            this.LocalsListVM.CollectionChanged += LocalsListVM_CollectionChanged;
            this.ExceptionHandlersListVM.CollectionChanged += ExceptionHandlersListVM_CollectionChanged;
            this.maxStack = new UInt16VM(a => CallHasErrorUpdated());
            this.localVarSigTok = new UInt32VM(a => CallHasErrorUpdated());
            this.headerSize = new ByteVM(a => CallHasErrorUpdated());
            this.headerRVA = new UInt32VM(a => CallHasErrorUpdated());
            this.headerFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            this.rva = new UInt32VM(a => CallHasErrorUpdated());
            this.fileOffset = new UInt64VM(a => CallHasErrorUpdated());

            Reinitialize();
        }
Beispiel #2
0
		public SwitchOperandVM(IList<InstructionVM> allInstrs, IList<InstructionVM> instrs) {
			AllInstructionsVM = new ListVM<InstructionVM>(allInstrs);
			origInstructions = instrs;
			InstructionsListVM = new IndexObservableCollection<SwitchInstructionVM>();

			Reinitialize();
		}
Beispiel #3
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            this.ownerMethod = ownerMethod;
            this.origOptions = options;

            typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language)
            {
                CanAddGenericTypeVar   = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            this.localsListVM                                  = new IndexObservableCollection <LocalVM>(() => new LocalVM(typeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            this.instructionsListVM                            = new IndexObservableCollection <InstructionVM>(() => CreateInstructionVM());
            this.exceptionHandlersListVM                       = new IndexObservableCollection <ExceptionHandlerVM>(() => new ExceptionHandlerVM(typeSigCreatorOptions, new ExceptionHandlerOptions()));
            this.LocalsListVM.UpdateIndexesDelegate            = LocalsUpdateIndexes;
            this.InstructionsListVM.UpdateIndexesDelegate      = InstructionsUpdateIndexes;
            this.ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            this.InstructionsListVM.CollectionChanged         += InstructionsListVM_CollectionChanged;
            this.LocalsListVM.CollectionChanged               += LocalsListVM_CollectionChanged;
            this.ExceptionHandlersListVM.CollectionChanged    += ExceptionHandlersListVM_CollectionChanged;
            this.maxStack         = new UInt16VM(a => CallHasErrorUpdated());
            this.localVarSigTok   = new UInt32VM(a => CallHasErrorUpdated());
            this.headerSize       = new ByteVM(a => CallHasErrorUpdated());
            this.headerRVA        = new UInt32VM(a => CallHasErrorUpdated());
            this.headerFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            this.rva        = new UInt32VM(a => CallHasErrorUpdated());
            this.fileOffset = new UInt64VM(a => CallHasErrorUpdated());

            Reinitialize();
        }
Beispiel #4
0
        public SwitchOperandVM(IList <InstructionVM> allInstrs, IList <InstructionVM> instrs)
        {
            this.allInstructionsVM  = new ListVM <InstructionVM>(allInstrs);
            this.origInstructions   = instrs;
            this.instructionsListVM = new IndexObservableCollection <SwitchInstructionVM>();

            Reinitialize();
        }
Beispiel #5
0
        public CilBodyVM(CilBodyOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod, bool initialize)
        {
            OwnerModule      = ownerModule;
            this.ownerMethod = ownerMethod;
            origOptions      = options;

            TypeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                CanAddGenericTypeVar   = ownerType.HasGenericParameters,
                CanAddGenericMethodVar = ownerMethod.MethodSig.GetGenParamCount() > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            LocalsListVM                                  = new LocalsIndexObservableCollection(this, () => new LocalVM(TypeSigCreatorOptions, new LocalOptions(new Local(ownerModule.CorLibTypes.Int32))));
            InstructionsListVM                            = new IndexObservableCollection <InstructionVM>(() => CreateInstructionVM());
            ExceptionHandlersListVM                       = new IndexObservableCollection <ExceptionHandlerVM>(() => new ExceptionHandlerVM(TypeSigCreatorOptions, new ExceptionHandlerOptions()));
            LocalsListVM.UpdateIndexesDelegate            = LocalsUpdateIndexes;
            InstructionsListVM.UpdateIndexesDelegate      = InstructionsUpdateIndexes;
            ExceptionHandlersListVM.UpdateIndexesDelegate = ExceptionHandlersUpdateIndexes;
            InstructionsListVM.CollectionChanged         += InstructionsListVM_CollectionChanged;
            LocalsListVM.CollectionChanged               += LocalsListVM_CollectionChanged;
            ExceptionHandlersListVM.CollectionChanged    += ExceptionHandlersListVM_CollectionChanged;
            MaxStack         = new UInt16VM(a => CallHasErrorUpdated());
            LocalVarSigTok   = new UInt32VM(a => CallHasErrorUpdated());
            HeaderSize       = new ByteVM(a => CallHasErrorUpdated());
            HeaderRVA        = new UInt32VM(a => CallHasErrorUpdated());
            HeaderFileOffset = new UInt64VM(a => CallHasErrorUpdated());
            RVA        = new UInt32VM(a => CallHasErrorUpdated());
            FileOffset = new UInt64VM(a => CallHasErrorUpdated());

            if (initialize)
            {
                Reinitialize();
            }
        }