}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void setup_internal_class (TypeBuilder tb);
+ private extern void setup_internal_class ();
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void create_internal_class (TypeBuilder tb);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void setup_generic_class ();
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void create_generic_class ();
this.nspace = String.Empty;
this.fullname = TypeIdentifiers.WithoutEscape(this.tname);
pmodule = mb;
- setup_internal_class (this);
+ setup_internal_class ();
}
internal TypeBuilder (ModuleBuilder mb, string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packing_size, int type_size, Type nesting_type)
{
int sep_index;
- this.parent = parent;
+ this.parent = ResolveUserType (parent);
this.attrs = attr;
this.class_size = type_size;
this.packing_size = packing_size;
// skip .<Module> ?
table_idx = mb.get_next_table_index (this, 0x02, true);
- setup_internal_class (this);
+ setup_internal_class ();
fullname = GetFullName ();
}
fields = new FieldBuilder [1];
fields [0] = res;
num_fields ++;
- create_internal_class (this);
}
if (IsEnum) {
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern TypeInfo create_runtime_class (TypeBuilder tb);
+ private extern TypeInfo create_runtime_class ();
private bool is_nested_in (Type t)
{
ctor.fixup ();
}
- created = create_runtime_class (this);
+ ResolveUserTypes ();
+
+ created = create_runtime_class ();
if (created != null)
return created;
return this;
}
+ void ResolveUserTypes () {
+ parent = ResolveUserType (parent);
+ ResolveUserTypes (interfaces);
+ if (fields != null) {
+ foreach (var fb in fields) {
+ if (fb != null)
+ fb.ResolveUserTypes ();
+ }
+ }
+ if (methods != null) {
+ foreach (var mb in methods) {
+ if (mb != null)
+ mb.ResolveUserTypes ();
+ }
+ }
+ if (ctors != null) {
+ foreach (var cb in ctors) {
+ if (cb != null)
+ cb.ResolveUserTypes ();
+ }
+ }
+ }
+
+ static internal void ResolveUserTypes (Type[] types) {
+ if (types != null)
+ for (int i = 0; i < types.Length; ++i)
+ types [i] = ResolveUserType (types [i]);
+ }
+
+ static internal Type ResolveUserType (Type t) {
+ if (t != null && ((t.GetType ().Assembly != typeof (int).Assembly) || (t is TypeDelegator))) {
+ t = t.UnderlyingSystemType;
+ if (t != null && ((t.GetType ().Assembly != typeof (int).Assembly) || (t is TypeDelegator)))
+ throw new NotSupportedException ("User defined subclasses of System.Type are not yet supported.");
+ return t;
+ } else {
+ return t;
+ }
+ }
+
internal void GenerateDebugInfo (ISymbolWriter symbolWriter)
{
symbolWriter.OpenNamespace (this.Namespace);
} else {
this.parent = parent;
}
+ this.parent = ResolveUserType (this.parent);
// will just set the parent-related bits if called a second time
- setup_internal_class (this);
+ setup_internal_class ();
}
internal int get_next_table_index (object obj, int table, bool inc) {
if (names.Length == 0)
throw new ArgumentException ("names");
- setup_generic_class ();
-
generic_params = new GenericTypeParameterBuilder [names.Length];
for (int i = 0; i < names.Length; i++) {
string item = names [i];