internal ILGenerator (MethodBase mb, int size) {
if (size < 0)
- size = 256;
+ size = 128;
code_len = 0;
code = new byte [size];
mbuilder = mb;
cur_stack = max_stack = 0;
num_fixups = num_labels = 0;
- label_to_addr = new int [16];
- fixups = new LabelFixup [16];
- token_fixups = new ILTokenInfo [16];
- scopes = new Stack ();
+ label_to_addr = new int [8];
+ fixups = new LabelFixup [8];
+ token_fixups = new ILTokenInfo [8];
num_token_fixups = 0;
if (mb is MethodBuilder) {
module = (ModuleBuilder)((MethodBuilder)mb).TypeBuilder.Module;
ex_handlers [cur_block].AddFinally (code_len);
}
public virtual void BeginScope () {
- if (sym_writer != null)
+ if (sym_writer != null) {
+ if (scopes == null)
+ scopes = new Stack ();
scopes.Push (sym_writer.OpenScope (code_len));
+ }
}
public LocalBuilder DeclareLocal (Type localType) {
LocalBuilder res = new LocalBuilder (module, localType, this);
public virtual void EndScope () {
if (sym_writer != null) {
sym_writer.CloseScope (code_len);
+ if (scopes == null)
+ throw new InvalidOperationException ();
scopes.Pop ();
}
}
private int class_size;
private PackingSize packing_size;
private Type created;
+ string fullname;
public const int UnspecifiedTypeSize = 0;
this.parent = null;
this.attrs = attr;
this.class_size = -1;
- this.tname = "<Module>";
+ fullname = this.tname = "<Module>";
this.nspace = "";
pmodule = mb;
setup_internal_class (this);
// skip .<Module> ?
table_idx = mb.get_next_table_index (this, 0x02, true);
setup_internal_class (this);
+ fullname = GetFullName ();
}
public override Assembly Assembly {
}
public override string AssemblyQualifiedName {
get {
- return FullName + ", " + Assembly.ToString();
+ return fullname + ", " + Assembly.ToString();
}
}
public override Type BaseType {
}
}
+ string GetFullName () {
+ if (nesting_type != null)
+ return String.Concat (nesting_type.FullName, "+", tname);
+ if ((nspace != null) && (nspace.Length > 0))
+ return String.Concat (nspace, ".", tname);
+ return tname;
+ }
+
public override string FullName {
get {
- if (nesting_type != null)
- return String.Concat (nesting_type.FullName, "+", tname);
- if ((nspace != null) && (nspace.Length > 0))
- return String.Concat (nspace, ".", tname);
- return tname;
+ return fullname;
}
}
private TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packsize, int typesize) {
TypeBuilder res = new TypeBuilder (pmodule, name, attr, parent, interfaces, packsize, typesize);
res.nesting_type = this;
+ res.fullname = res.GetFullName ();
if (subtypes != null) {
TypeBuilder[] new_types = new TypeBuilder [subtypes.Length + 1];
System.Array.Copy (subtypes, new_types, subtypes.Length);