Add another InstructionEmulator.Initialize() method

This commit is contained in:
de4dot 2014-04-21 15:24:24 +02:00
parent 9de80a0e07
commit b0ee9e987f

View File

@ -52,8 +52,12 @@ namespace de4dot.blocks.cflow {
} }
public void Initialize(MethodDef method, bool emulateFromFirstInstruction) { public void Initialize(MethodDef method, bool emulateFromFirstInstruction) {
this.parameterDefs = method.Parameters; Initialize(method, method.Parameters, method.Body.Variables, method.Body.InitLocals, emulateFromFirstInstruction);
this.localDefs = method.Body.Variables; }
public void Initialize(MethodDef method, IList<Parameter> methodParameters, IList<Local> methodLocals, bool initLocals, bool emulateFromFirstInstruction) {
this.parameterDefs = methodParameters;
this.localDefs = methodLocals;
valueStack.Initialize(); valueStack.Initialize();
protectedStackValues.Clear(); protectedStackValues.Clear();
@ -75,7 +79,7 @@ namespace de4dot.blocks.cflow {
args.Clear(); args.Clear();
args.AddRange(cached_args); args.AddRange(cached_args);
locals.Clear(); locals.Clear();
locals.AddRange(method.Body.InitLocals && emulateFromFirstInstruction ? cached_zeroed_locals : cached_locals); locals.AddRange(initLocals && emulateFromFirstInstruction ? cached_zeroed_locals : cached_locals);
} }
public void SetProtected(Value value) { public void SetProtected(Value value) {