public LocalVariableEntry[] GetLocals() { lock (SymbolFile) { if (locals != null) { return(locals); } if (LocalVariableTableOffset == 0) { return(null); } MyBinaryReader reader = SymbolFile.BinaryReader; long old_pos = reader.BaseStream.Position; reader.BaseStream.Position = LocalVariableTableOffset; int num_locals = reader.ReadLeb128(); locals = new LocalVariableEntry [num_locals]; for (int i = 0; i < num_locals; i++) { locals [i] = new LocalVariableEntry(SymbolFile, reader); } reader.BaseStream.Position = old_pos; return(locals); } }
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); } } }
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 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 LocalVariableEntry[] GetLocals () { lock (SymbolFile) { if (locals != null) return locals; if (LocalVariableTableOffset == 0) return null; MyBinaryReader reader = SymbolFile.BinaryReader; long old_pos = reader.BaseStream.Position; reader.BaseStream.Position = LocalVariableTableOffset; int num_locals = reader.ReadLeb128 (); locals = new LocalVariableEntry [num_locals]; for (int i = 0; i < num_locals; i++) locals [i] = new LocalVariableEntry (SymbolFile, reader); reader.BaseStream.Position = old_pos; return locals; } }
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 LocalVariableEntry[] GetLocalVars() { System.IO.MemoryStream str = new System.IO.MemoryStream(); int i = 0; int num_locals = ((Hashtable) named_local_tables [current_scope_depth]).Count; LocalVariableEntry[] locals = new LocalVariableEntry[num_locals]; foreach (Local local in local_list) { if (local.Name != null) { // only named variables locals[i++] = new LocalVariableEntry(local.Slot, local.Name, 0); } } return locals; }