LexicalBlocks = blocks;
NumLexicalBlocks = LexicalBlocks.Length;
- LineNumbers = BuildLineNumberTable (lines);
+ LineNumbers = lines;
NumLineNumbers = LineNumbers.Length;
ParameterInfo[] parameters = method.GetParameters ();
if (parameters == null)
parameters = new ParameterInfo [0];
-
- StringBuilder sb = new StringBuilder ();
- sb.Append (method.DeclaringType.FullName);
- sb.Append (".");
- sb.Append (method.Name);
- sb.Append ("(");
- for (int i = 0; i < parameters.Length; i++) {
- if (i > 0)
- sb.Append (",");
- sb.Append (parameters [i].ParameterType.FullName);
+
+ if (parameters.Length == 0)
+ full_name = method.DeclaringType.FullName + "." + method.Name + "()";
+ else if (parameters.Length == 1)
+ full_name = method.DeclaringType.FullName + "." + method.Name + "(" + parameters [0].ParameterType.FullName + ")";
+ else if (parameters.Length == 2)
+ full_name = method.DeclaringType.FullName + "." + method.Name + "(" + parameters [0].ParameterType.FullName + "," + parameters [1].ParameterType.FullName + ")";
+ else {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (method.DeclaringType.FullName);
+ sb.Append (".");
+ sb.Append (method.Name);
+ sb.Append ("(");
+ for (int i = 0; i < parameters.Length; i++) {
+ if (i > 0)
+ sb.Append (",");
+ sb.Append (parameters [i].ParameterType.FullName);
+ }
+ sb.Append (")");
+ full_name = sb.ToString ();
}
- sb.Append (")");
name = method.Name;
- full_name = sb.ToString ();
-
+
NumParameters = parameters.Length;
ParamTypeIndices = new int [NumParameters];
for (int i = 0; i < NumParameters; i++)
NumLocals = locals.Length;
Locals = locals;
- Hashtable local_names = new Hashtable ();
- foreach (LocalVariableEntry local in locals) {
- if (local_names.Contains (local.Name)) {
- LocalNamesAmbiguous = true;
- break;
+ if (NumLocals <= 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 < NumLocals; i ++) {
+ string nm = locals [i].Name;
+
+ for (int j = i + 1; j < NumLocals; j ++) {
+ if (locals [j].Name == nm) {
+ LocalNamesAmbiguous = true;
+ goto locals_check_done;
+ }
+ }
+ }
+ locals_check_done :
+ ;
+ } else {
+ Hashtable local_names = new Hashtable ();
+ foreach (LocalVariableEntry local in locals) {
+ if (local_names.Contains (local.Name)) {
+ LocalNamesAmbiguous = true;
+ break;
+ }
+ local_names.Add (local.Name, local);
}
- local_names.Add (local.Name, local);
}
LocalTypeIndices = new int [NumLocals];
ClassTypeIndex = file.DefineType (method.ReflectedType);
}
- LineNumberEntry[] BuildLineNumberTable (LineNumberEntry[] line_numbers)
- {
- ArrayList list = new ArrayList ();
- int last_offset = -1;
- int last_row = -1;
-
- for (int i = 0; i < line_numbers.Length; i++) {
- LineNumberEntry line = (LineNumberEntry) line_numbers [i];
-
- if (line.Offset > last_offset) {
- if (last_row >= 0)
- list.Add (new LineNumberEntry (last_row, last_offset));
- last_row = line.Row;
- last_offset = line.Offset;
- } else if (line.Row > last_row) {
- last_row = line.Row;
- }
- }
-
- if (last_row >= 0)
- list.Add (new LineNumberEntry (last_row, last_offset));
-
- LineNumberEntry[] retval = new LineNumberEntry [list.Count];
- list.CopyTo (retval, 0);
- return retval;
- }
-
internal MethodSourceEntry Write (MonoSymbolFile file, BinaryWriter bw)
{
NameOffset = (int) bw.BaseStream.Position;