static void ReadLocalVariables (MethodEntry entry, MethodBody body, Scope [] scopes) { var locals = entry.GetLocals (); foreach (var local in locals) { var variable = body.Variables [local.Index]; variable.Name = local.Name; var index = local.BlockIndex; if (index < 0 || index >= scopes.Length) continue; var scope = scopes [index]; if (scope == null) continue; scope.Variables.Add (variable); } }
private static void ReadLocalVariables(MethodEntry entry, MethodBody body, Scope[] scopes) { LocalVariableEntry[] locals = entry.GetLocals(); LocalVariableEntry[] array = locals; for (int i = 0; i < array.Length; i++) { LocalVariableEntry local = array[i]; VariableDefinition variable = body.Variables[local.Index]; variable.Name = local.Name; int index = local.BlockIndex; if (index >= 0 && index < scopes.Length) { Scope scope = scopes[index]; if (scope != null) { scope.Variables.Add(variable); } } } }
static bool AddScope (Scope provider, Scope scope) { foreach (var sub_scope in provider.Scopes) { if (AddScope (sub_scope, scope)) return true; if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) { sub_scope.Scopes.Add (scope); return true; } } return false; }
void WriteScope(MethodBody body, Scope scope) { var start_offset = scope.Start.Offset; var end_offset = scope.End.Next != null ? scope.End.Next.Offset : body.CodeSize; writer.OpenScope (start_offset); foreach (var s in scope.Scopes) WriteScope (body, s); DefineVariables (body, scope.Variables, start_offset, end_offset) ; writer.CloseScope (end_offset); }
private void WriteScope (Scope scope, bool root) { if (scope.Start.Offset == scope.End.Offset) return; writer.OpenScope (scope.Start.Offset); if (scope.HasVariables) { foreach (var el in scope.Variables) { if (!String.IsNullOrEmpty (el.Name)) writer.DefineLocalVariable (el.Index, el.Name); } } if (scope.HasScopes) { foreach (var el in scope.Scopes) WriteScope (el, false); } writer.CloseScope (scope.End.Offset + scope.End.GetSize()); }
public void VisitScope (Scope s) { }
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 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; }
public override void VisitScope(Scope scope) { Apply(visitor => visitor.VisitScope(scope)); }
public override void VisitScope(Scope s) { base.VisitScope(s); }
static void SetLvHandler(Scope scope, MethodBody body, IList<Instruction> block) { foreach (var i in scope.Type.Scopes) { if (i.Item1 == null) return; switch (i.Item2) { case ScopeType.TryOnly: i.Item1.TryStart = block[0]; i.Item1.TryEnd = block[block.Count - 1]; break; case ScopeType.TryStart: i.Item1.TryStart = block[0]; break; case ScopeType.TryEnd: i.Item1.TryEnd = block[block.Count - 1]; break; case ScopeType.HandlerOnly: i.Item1.HandlerStart = block[0]; i.Item1.HandlerEnd = block[block.Count - 1]; break; case ScopeType.HandlerStart: i.Item1.HandlerStart = block[0]; break; case ScopeType.HandlerEnd: i.Item1.HandlerEnd = block[block.Count - 1]; break; case ScopeType.FilterOnly: case ScopeType.FilterStart: i.Item1.FilterStart = block[0]; break; } } }
bool AddScope (IScopeProvider provider, Scope s) { foreach (Scope scope in provider.Scopes) { if (AddScope (scope, s)) return true; if (s.Start.Offset >= scope.Start.Offset && s.End.Offset <= scope.End.Offset) { scope.Scopes.Add (s); return true; } } return false; }
void ReadScopes (MethodEntry entry, MethodBody body, IDictionary instructions) { CodeBlockEntry[] blocks = entry.GetCodeBlocks (); foreach (CodeBlockEntry cbe in blocks) { if (cbe.BlockType != CodeBlockEntry.Type.Lexical) continue; Scope s = new Scope (); s.Start = GetInstruction (body, instructions, cbe.StartOffset); s.End = GetInstruction(body, instructions, cbe.EndOffset); m_scopes [entry.Index] = s; if (!AddScope (body, s)) body.Scopes.Add (s); } }
private static Scope[] ReadScopes(MethodEntry entry, MethodBody body, InstructionMapper mapper) { CodeBlockEntry[] blocks = entry.GetCodeBlocks(); Scope[] scopes = new Scope[blocks.Length]; CodeBlockEntry[] array = blocks; for (int i = 0; i < array.Length; i++) { CodeBlockEntry block = array[i]; if (block.BlockType == CodeBlockEntry.Type.Lexical) { Scope scope = new Scope(); scope.Start = mapper(block.StartOffset); scope.End = mapper(block.EndOffset); scopes[block.Index] = scope; if (body.Scope == null) { body.Scope = scope; } if (!MdbReader.AddScope(body.Scope, scope)) { body.Scope = scope; } } } return scopes; }
public void Remove (Scope value) { List.Remove (value); }
public override void VisitScope(Scope scope) { }
public virtual void VisitScope(Scope scope) { }
static void ReadScopeAndLocals(PdbScope [] scopes, Scope parent, MethodBody body, InstructionMapper mapper) { foreach (PdbScope scope in scopes) ReadScopeAndLocals (scope, parent, body, mapper); CreateRootScope (body); }
static void ReadScopeAndLocals(PdbScope scope, Scope parent, MethodBody body, InstructionMapper mapper) { if (scope == null) return; Scope s = new Scope (); SetInstructionRange (body, mapper, s, scope.offset, scope.length); if (parent != null) parent.Scopes.Add (s); else if (body.Scope == null) body.Scope = s; else throw new InvalidDataException () ; 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, s, body, mapper); }
public void VisitScope(Scope scope) { throw new NotImplementedException(); }
static void ReadScopeAndLocals (PdbScope [] scopes, Scope parent, MethodBody body, IDictionary instructions) { foreach (PdbScope scope in scopes) ReadScopeAndLocals (scope, parent, body, instructions); }
private Scope CreateScope(FunctionCompilerContext functionContext, Scope parentScope, Mono.Cecil.Cil.Scope cecilScope) { var newScope = new Scope(cecilScope); var sequencePoint = newScope.Source.Start.SequencePoint; if (sequencePoint != null) { newScope.GeneratedScope = LLVM.DIBuilderCreateLexicalBlock(debugBuilder, parentScope.GeneratedScope, functionContext.DebugFile, (uint)sequencePoint.StartLine, (uint)sequencePoint.StartColumn, 0); } return(newScope); }
public void Add (Scope value) { List.Add (value); }
void addScope(Scope scope) { if (scope == null) return; addVariableDefinitions(scope.Variables); addScopes(scope.Scopes); }
public bool Contains (Scope value) { return List.Contains (value); }
static Scope [] ReadScopes (MethodEntry entry, MethodBody body, InstructionMapper mapper) { var blocks = entry.GetCodeBlocks (); var scopes = new Scope [blocks.Length]; foreach (var block in blocks) { if (block.BlockType != CodeBlockEntry.Type.Lexical) continue; var scope = new Scope (); scope.Start = mapper (block.StartOffset); scope.End = mapper (block.EndOffset); scopes [block.Index] = scope; if (body.Scope == null) body.Scope = scope; if (!AddScope (body.Scope, scope)) body.Scope = scope; } return scopes; }
public int IndexOf (Scope value) { return List.IndexOf (value); }
public void Insert (int index, Scope value) { List.Insert (index, value); }
private static bool AddScope(Scope provider, Scope scope) { bool result; foreach (Scope sub_scope in provider.Scopes) { if (MdbReader.AddScope(sub_scope, scope)) { result = true; return result; } if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) { sub_scope.Scopes.Add(scope); result = true; return result; } } result = false; return result; }