CECIL = $(topdir)/class/lib/$(PROFILE)/Mono.Cecil.dll
-LIB_MCS_FLAGS = /r:$(corlib) /r:$(CECIL) /d:CECIL -keyfile:$(LIBRARY_SNK)
+LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:$(CECIL) /d:CECIL -keyfile:$(LIBRARY_SNK)
NO_TEST = yes
LIBRARY = Mono.CompilerServices.SymbolWriter.dll
LIBRARY_USE_INTERMEDIATE_FILE = yes
-LIB_MCS_FLAGS = /r:$(corlib)
+LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll
NO_TEST = yes
ifneq (basic, $(PROFILE))
using System;
using System.Reflection;
using SRE = System.Reflection.Emit;
-using System.Collections;
+using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.IO;
public class MonoSymbolFile : IDisposable
{
- ArrayList methods = new ArrayList ();
- ArrayList sources = new ArrayList ();
- ArrayList comp_units = new ArrayList ();
- Hashtable type_hash = new Hashtable ();
- Hashtable anonymous_scopes;
+ List<MethodEntry> methods = new List<MethodEntry> ();
+ List<SourceFileEntry> sources = new List<SourceFileEntry> ();
+ List<CompileUnitEntry> comp_units = new List<CompileUnitEntry> ();
+ Dictionary<Type, int> type_hash = new Dictionary<Type, int> ();
+ Dictionary<int, AnonymousScopeEntry> anonymous_scopes;
OffsetTable ot;
int last_type_index;
internal int DefineType (Type type)
{
- if (type_hash.Contains (type))
- return (int) type_hash [type];
+ int index;
+ if (type_hash.TryGetValue (type, out index))
+ return index;
- int index = ++last_type_index;
+ index = ++last_type_index;
type_hash.Add (type, index);
return index;
}
throw new InvalidOperationException ();
if (anonymous_scopes == null)
- anonymous_scopes = new Hashtable ();
+ anonymous_scopes = new Dictionary<int, AnonymousScopeEntry> ();
anonymous_scopes.Add (id, new AnonymousScopeEntry (id));
}
if (reader != null)
throw new InvalidOperationException ();
- AnonymousScopeEntry scope = (AnonymousScopeEntry) anonymous_scopes [scope_id];
+ AnonymousScopeEntry scope = anonymous_scopes [scope_id];
scope.AddCapturedVariable (name, captured_name, kind);
}
if (reader != null)
throw new InvalidOperationException ();
- AnonymousScopeEntry scope = (AnonymousScopeEntry) anonymous_scopes [scope_id];
+ AnonymousScopeEntry scope = anonymous_scopes [scope_id];
scope.AddCapturedScope (id, captured_name);
}
}
MyBinaryReader reader;
- Hashtable source_file_hash;
- Hashtable compile_unit_hash;
+ Dictionary<int, SourceFileEntry> source_file_hash;
+ Dictionary<int, CompileUnitEntry> compile_unit_hash;
- ArrayList method_list;
- Hashtable method_token_hash;
- Hashtable source_name_hash;
+ List<MethodEntry> method_list;
+ Dictionary<int, MethodEntry> method_token_hash;
+ Dictionary<string, int> source_name_hash;
Guid guid;
"Cannot read symbol file `{0}'", filename);
}
- source_file_hash = new Hashtable ();
- compile_unit_hash = new Hashtable ();
+ source_file_hash = new Dictionary<int, SourceFileEntry> ();
+ compile_unit_hash = new Dictionary<int, CompileUnitEntry> ();
}
void CheckGuidMatch (Guid other, string filename, string assembly)
throw new InvalidOperationException ();
lock (this) {
- SourceFileEntry source = (SourceFileEntry) source_file_hash [index];
- if (source != null)
+ SourceFileEntry source;
+ if (source_file_hash.TryGetValue (index, out source))
return source;
long old_pos = reader.BaseStream.Position;
throw new InvalidOperationException ();
lock (this) {
- CompileUnitEntry unit = (CompileUnitEntry) compile_unit_hash [index];
- if (unit != null)
+ CompileUnitEntry unit;
+ if (compile_unit_hash.TryGetValue (index, out unit))
return unit;
long old_pos = reader.BaseStream.Position;
if (method_token_hash != null)
return;
- method_token_hash = new Hashtable ();
- method_list = new ArrayList ();
+ method_token_hash = new Dictionary<int, MethodEntry> ();
+ method_list = new List<MethodEntry> ();
long old_pos = reader.BaseStream.Position;
reader.BaseStream.Position = ot.MethodTableOffset;
lock (this) {
read_methods ();
- return (MethodEntry) method_token_hash [token];
+ MethodEntry me;
+ method_token_hash.TryGetValue (token, out me);
+ return me;
}
}
lock (this) {
if (source_name_hash == null) {
- source_name_hash = new Hashtable ();
+ source_name_hash = new Dictionary<string, int> ();
for (int i = 0; i < ot.SourceCount; i++) {
SourceFileEntry source = GetSourceFile (i + 1);
}
}
- object value = source_name_hash [file_name];
- if (value == null)
+ int value;
+ if (!source_name_hash.TryGetValue (file_name, out value))
return -1;
- return (int) value;
+ return value;
}
}
if (reader == null)
throw new InvalidOperationException ();
+ AnonymousScopeEntry scope;
lock (this) {
- if (anonymous_scopes != null)
- return (AnonymousScopeEntry) anonymous_scopes [id];
+ if (anonymous_scopes != null) {
+ anonymous_scopes.TryGetValue (id, out scope);
+ return scope;
+ }
- anonymous_scopes = new Hashtable ();
+ anonymous_scopes = new Dictionary<int, AnonymousScopeEntry> ();
reader.BaseStream.Position = ot.AnonymousScopeTableOffset;
for (int i = 0; i < ot.AnonymousScopeCount; i++) {
- AnonymousScopeEntry scope = new AnonymousScopeEntry (reader);
+ scope = new AnonymousScopeEntry (reader);
anonymous_scopes.Add (scope.ID, scope);
}
- return (AnonymousScopeEntry) anonymous_scopes [id];
+ return anonymous_scopes [id];
}
}
using System;
using System.Security.Cryptography;
-using System.Collections;
+using System.Collections.Generic;
using System.Text;
using System.IO;
public static LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
- private class OffsetComparerClass : IComparer
+ private class OffsetComparerClass : IComparer<LineNumberEntry>
{
- public int Compare (object a, object b)
+ public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
- LineNumberEntry l1 = (LineNumberEntry) a;
- LineNumberEntry l2 = (LineNumberEntry) b;
-
if (l1.Offset < l2.Offset)
return -1;
else if (l1.Offset > l2.Offset)
}
}
- private class RowComparerClass : IComparer
+ private class RowComparerClass : IComparer<LineNumberEntry>
{
- public int Compare (object a, object b)
+ public int Compare (LineNumberEntry l1, LineNumberEntry l2)
{
- LineNumberEntry l1 = (LineNumberEntry) a;
- LineNumberEntry l2 = (LineNumberEntry) b;
-
if (l1.Row < l2.Row)
return -1;
else if (l1.Row > l2.Row)
}
}
- public static readonly IComparer OffsetComparer = new OffsetComparerClass ();
- public static readonly IComparer RowComparer = new RowComparerClass ();
+ public static readonly IComparer<LineNumberEntry> OffsetComparer = new OffsetComparerClass ();
+ public static readonly IComparer<LineNumberEntry> RowComparer = new RowComparerClass ();
public override string ToString ()
{
public readonly int ID;
#endregion
- ArrayList captured_vars = new ArrayList ();
- ArrayList captured_scopes = new ArrayList ();
+ List<CapturedVariable> captured_vars = new List<CapturedVariable> ();
+ List<CapturedScope> captured_scopes = new List<CapturedScope> ();
public AnonymousScopeEntry (int id)
{
MonoSymbolFile file;
SourceFileEntry source;
- ArrayList include_files;
- ArrayList namespaces;
+ List<SourceFileEntry> include_files;
+ List<NamespaceEntry> namespaces;
bool creating;
this.Index = file.AddCompileUnit (this);
creating = true;
- namespaces = new ArrayList ();
+ namespaces = new List<NamespaceEntry> ();
}
public void AddFile (SourceFileEntry file)
throw new InvalidOperationException ();
if (include_files == null)
- include_files = new ArrayList ();
+ include_files = new List<SourceFileEntry> ();
include_files.Add (file);
}
int count_includes = reader.ReadLeb128 ();
if (count_includes > 0) {
- include_files = new ArrayList ();
+ include_files = new List<SourceFileEntry> ();
for (int i = 0; i < count_includes; i++)
include_files.Add (file.GetSourceFile (reader.ReadLeb128 ()));
}
int count_ns = reader.ReadLeb128 ();
- namespaces = new ArrayList ();
+ namespaces = new List<NamespaceEntry> ();
for (int i = 0; i < count_ns; i ++)
namespaces.Add (new NamespaceEntry (file, reader));
void DoRead (MonoSymbolFile file, MyBinaryReader br)
{
- ArrayList lines = new ArrayList ();
+ var lines = new List<LineNumberEntry> ();
bool is_hidden = false, modified = false;
int stm_line = 1, stm_offset = 0, stm_file = 1;
locals_check_done :
;
} else {
- Hashtable local_names = new Hashtable ();
+ var local_names = new Dictionary<string, LocalVariableEntry> ();
foreach (LocalVariableEntry local in locals) {
- if (local_names.Contains (local.Name)) {
+ if (local_names.ContainsKey (local.Name)) {
flags |= Flags.LocalNamesAmbiguous;
break;
}
using System;
using System.Runtime.CompilerServices;
-using System.Collections;
+using System.Collections.Generic;
using System.IO;
namespace Mono.CompilerServices.SymbolWriter
{
public class MonoSymbolWriter
{
- ArrayList methods = null;
- ArrayList sources = null;
- ArrayList comp_units = null;
+ List<SourceMethodBuilder> methods;
+ List<SourceFileEntry> sources;
+ List<CompileUnitEntry> comp_units;
protected readonly MonoSymbolFile file;
- string filename = null;
+ string filename;
- private SourceMethodBuilder current_method = null;
- private Stack current_method_stack;
+ private SourceMethodBuilder current_method;
+ private Stack<SourceMethodBuilder> current_method_stack;
public MonoSymbolWriter (string filename)
{
- this.methods = new ArrayList ();
- this.sources = new ArrayList ();
- this.comp_units = new ArrayList ();
- this.current_method_stack = new Stack ();
+ this.methods = new List<SourceMethodBuilder> ();
+ this.sources = new List<SourceFileEntry> ();
+ this.comp_units = new List<CompileUnitEntry> ();
+ this.current_method_stack = new Stack<SourceMethodBuilder> ();
this.file = new MonoSymbolFile ();
this.filename = filename + ".mdb";
public class SourceMethodBuilder
{
- ArrayList _locals;
- ArrayList _blocks;
- ArrayList _scope_vars;
- Stack _block_stack;
+ List<LocalVariableEntry> _locals;
+ List<CodeBlockEntry> _blocks;
+ List<ScopeVariable> _scope_vars;
+ Stack<CodeBlockEntry> _block_stack;
string _real_name;
IMethodDef _method;
ICompileUnit _comp_unit;
public void StartBlock (CodeBlockEntry.Type type, int start_offset)
{
if (_block_stack == null)
- _block_stack = new Stack ();
+ _block_stack = new Stack<CodeBlockEntry> ();
if (_blocks == null)
- _blocks = new ArrayList ();
+ _blocks = new List<CodeBlockEntry> ();
int parent = CurrentBlock != null ? CurrentBlock.Index : -1;
public void AddLocal (int index, string name)
{
if (_locals == null)
- _locals = new ArrayList ();
+ _locals = new List<LocalVariableEntry> ();
int block_idx = CurrentBlock != null ? CurrentBlock.Index : 0;
_locals.Add (new LocalVariableEntry (index, name, block_idx));
}
public void AddScopeVariable (int scope, int index)
{
if (_scope_vars == null)
- _scope_vars = new ArrayList ();
+ _scope_vars = new List<ScopeVariable> ();
_scope_vars.Add (
new ScopeVariable (scope, index));
}