public CodeBlockEntry[] GetCodeBlocks() { lock (SymbolFile) { if (code_blocks != null) { return(code_blocks); } if (CodeBlockTableOffset == 0) { return(null); } MyBinaryReader reader = SymbolFile.BinaryReader; long old_pos = reader.BaseStream.Position; reader.BaseStream.Position = CodeBlockTableOffset; int num_code_blocks = reader.ReadLeb128(); code_blocks = new CodeBlockEntry [num_code_blocks]; for (int i = 0; i < num_code_blocks; i++) { code_blocks [i] = new CodeBlockEntry(i, reader); } reader.BaseStream.Position = old_pos; return(code_blocks); } }
public CodeBlockEntry(int index, int parent, CodeBlockEntry.Type type, int start_offset) { this.Index = index; this.Parent = parent; this.BlockType = type; this.StartOffset = start_offset; }
internal MethodEntry(MonoSymbolFile file, CompileUnitEntry comp_unit, int token, ScopeVariable[] scope_vars, LocalVariableEntry[] locals, LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, string real_name, MethodEntry.Flags flags, int namespace_id) { this.SymbolFile = file; this.real_name = real_name; this.locals = locals; this.code_blocks = code_blocks; this.scope_vars = scope_vars; this.flags = flags; this.index = -1; this.Token = token; this.CompileUnitIndex = comp_unit.Index; this.CompileUnit = comp_unit; this.NamespaceID = namespace_id; this.CheckLineNumberTable(lines); this.lnt = new LineNumberTable(file, lines); file.NumLineNumbers += lines.Length; int num_locals = (locals != null) ? locals.Length : 0; if (num_locals <= 32) { for (int i = 0; i < num_locals; i++) { string nm = locals[i].Name; for (int j = i + 1; j < num_locals; j++) { if (locals[j].Name == nm) { flags |= MethodEntry.Flags.LocalNamesAmbiguous; goto IL_108; } } } IL_108:; } else { Dictionary<string, LocalVariableEntry> local_names = new Dictionary<string, LocalVariableEntry>(); for (int k = 0; k < locals.Length; k++) { LocalVariableEntry local = locals[k]; if (local_names.ContainsKey(local.Name)) { flags |= MethodEntry.Flags.LocalNamesAmbiguous; break; } local_names.Add(local.Name, local); } } }
public void StartBlock(CodeBlockEntry.Type type, int start_offset) { if (this._block_stack == null) { this._block_stack = new Stack <CodeBlockEntry>(); } if (this._blocks == null) { this._blocks = new List <CodeBlockEntry>(); } int parent = (this.CurrentBlock != null) ? this.CurrentBlock.Index : -1; CodeBlockEntry block = new CodeBlockEntry(this._blocks.Count + 1, parent, type, start_offset); this._block_stack.Push(block); this._blocks.Add(block); }
public void StartBlock (CodeBlockEntry.Type type, int start_offset) { if (_block_stack == null) { _block_stack = new Stack<CodeBlockEntry> (); } if (_blocks == null) _blocks = new List<CodeBlockEntry> (); int parent = CurrentBlock != null ? CurrentBlock.Index : -1; CodeBlockEntry block = new CodeBlockEntry ( _blocks.Count + 1, parent, type, start_offset); _block_stack.Push (block); _blocks.Add (block); }
public void StartBlock(CodeBlockEntry.Type type, int start_offset) { if (_block_stack == null) { _block_stack = new Stack(); } if (_blocks == null) { _blocks = new ArrayList(); } int parent = CurrentBlock != null ? CurrentBlock.Index : -1; CodeBlockEntry block = new CodeBlockEntry( _blocks.Count + 1, parent, type, start_offset); _block_stack.Push(block); _blocks.Add(block); }
public void StartBlock(CodeBlockEntry.Type type, int start_offset, int scopeIndex) { if (_block_stack == null) { _block_stack = new Stack <CodeBlockEntry> (); } if (_blocks == null) { _blocks = new List <CodeBlockEntry> (); } int parent = CurrentBlock != null ? CurrentBlock.Index : -1; CodeBlockEntry block = new CodeBlockEntry( scopeIndex, parent, type, start_offset); _block_stack.Push(block); _blocks.Add(block); }
public void StartBlock(CodeBlockEntry.Type type, int start_offset) { if (_block_stack == null) { #if NET_2_1 _block_stack = new System.Collections.Stack(); #else _block_stack = new Stack <CodeBlockEntry> (); #endif } if (_blocks == null) { _blocks = new List <CodeBlockEntry> (); } int parent = CurrentBlock != null ? CurrentBlock.Index : -1; CodeBlockEntry block = new CodeBlockEntry( _blocks.Count + 1, parent, type, start_offset); _block_stack.Push(block); _blocks.Add(block); }
public void EndBlock(int end_offset) { CodeBlockEntry block = (CodeBlockEntry)_block_stack.Pop(); block.Close(end_offset); }
public MethodEntry DefineMethod (CompileUnitEntry comp_unit, int token, ScopeVariable[] scope_vars, LocalVariableEntry[] locals, LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, string real_name, MethodEntry.Flags flags, int namespace_id) { if (reader != null) throw new InvalidOperationException (); MethodEntry method = new MethodEntry ( this, comp_unit, token, scope_vars, locals, lines, code_blocks, real_name, flags, namespace_id); AddMethod (method); return method; }
public CodeBlockEntry[] GetCodeBlocks () { lock (SymbolFile) { if (code_blocks != null) return code_blocks; if (CodeBlockTableOffset == 0) return null; MyBinaryReader reader = SymbolFile.BinaryReader; long old_pos = reader.BaseStream.Position; reader.BaseStream.Position = CodeBlockTableOffset; int num_code_blocks = reader.ReadLeb128 (); code_blocks = new CodeBlockEntry [num_code_blocks]; for (int i = 0; i < num_code_blocks; i++) code_blocks [i] = new CodeBlockEntry (i, reader); reader.BaseStream.Position = old_pos; return code_blocks; } }
internal MethodEntry (MonoSymbolFile file, CompileUnitEntry comp_unit, int token, ScopeVariable[] scope_vars, LocalVariableEntry[] locals, LineNumberEntry[] lines, CodeBlockEntry[] code_blocks, string real_name, Flags flags, int namespace_id) { this.SymbolFile = file; this.real_name = real_name; this.locals = locals; this.code_blocks = code_blocks; this.scope_vars = scope_vars; this.flags = flags; index = -1; Token = token; CompileUnitIndex = comp_unit.Index; CompileUnit = comp_unit; NamespaceID = namespace_id; CheckLineNumberTable (lines); lnt = new LineNumberTable (file, lines); file.NumLineNumbers += lines.Length; int num_locals = locals != null ? locals.Length : 0; if (num_locals <= 32) { // Most of the time, the O(n^2) factor is actually // less than the cost of allocating the hash table, // 32 is a rough number obtained through some testing. for (int i = 0; i < num_locals; i ++) { string nm = locals [i].Name; for (int j = i + 1; j < num_locals; j ++) { if (locals [j].Name == nm) { flags |= Flags.LocalNamesAmbiguous; goto locals_check_done; } } } locals_check_done : ; } else { Hashtable local_names = new Hashtable (); foreach (LocalVariableEntry local in locals) { if (local_names.Contains (local.Name)) { flags |= Flags.LocalNamesAmbiguous; break; } local_names.Add (local.Name, local); } } }
public void StartBlock (CodeBlockEntry.Type type, int start_offset) { StartBlock (type, start_offset, _blocks == null ? 1 : _blocks.Count + 1); }