static void CreateRootScope (MethodBody body) { if (!body.HasVariables) return; var instructions = body.Instructions; var root = new Scope (); root.Start = instructions [0]; root.End = instructions [instructions.Count - 1]; var variables = body.Variables; for (int i = 0; i < variables.Count; i++) root.Variables.Add (variables [i]); body.Scope = root; }
static void ReadScopeAndLocals (PdbScope scope, Scope parent, MethodBody body, InstructionMapper mapper) { //Scope s = new Scope (); //s.Start = GetInstruction (body, instructions, (int) scope.address); //s.End = GetInstruction (body, instructions, (int) scope.length - 1); //if (parent != null) // parent.Scopes.Add (s); //else // body.Scopes.Add (s); if (scope == null) return; foreach (PdbSlot slot in scope.slots) { int index = (int) slot.slot; if (index < 0 || index >= body.Variables.Count) continue; VariableDefinition variable = body.Variables [index]; variable.Name = slot.name; //s.Variables.Add (variable); } ReadScopeAndLocals (scope.scopes, null /* s */, body, mapper); }
static void ReadScopeAndLocals (PdbScope [] scopes, Scope parent, MethodBody body, InstructionMapper mapper) { foreach (PdbScope scope in scopes) ReadScopeAndLocals (scope, parent, body, mapper); CreateRootScope (body); }