public Type CreateType() { if ((typeFlags & TypeFlags.Baked) != 0) { // .NET allows multiple invocations (subsequent invocations return the same baked type) throw new NotImplementedException(); } typeFlags |= TypeFlags.Baked; foreach (MethodBuilder mb in methods) { mb.Bake(); } if (declarativeSecurity != null) { this.ModuleBuilder.AddDeclarativeSecurity(token, declarativeSecurity); } if (baseType != null) { extends = this.ModuleBuilder.GetTypeToken(baseType).Token; } if (interfaces != null) { foreach (Type interfaceType in interfaces) { InterfaceImplTable.Record rec = new InterfaceImplTable.Record(); rec.Class = token; rec.Interface = this.ModuleBuilder.GetTypeToken(interfaceType).Token; this.ModuleBuilder.InterfaceImpl.AddRecord(rec); } } return(new BakedType(this)); }
public void AddInterfaceImplementation(Type interfaceType) { if (interfaces == null) { interfaces = new List <Type>(); } interfaces.Add(interfaceType); InterfaceImplTable.Record rec = new InterfaceImplTable.Record(); rec.Class = token; rec.Interface = this.ModuleBuilder.GetTypeToken(interfaceType).Token; this.ModuleBuilder.InterfaceImpl.AddRecord(rec); }
public TypeInfo CreateTypeInfo() { if ((typeFlags & TypeFlags.Baked) != 0) { // .NET allows multiple invocations (subsequent invocations return the same baked type) throw new NotImplementedException(); } typeFlags |= TypeFlags.Baked; if (hasLayout) { ClassLayoutTable.Record rec = new ClassLayoutTable.Record(); rec.PackingSize = pack; rec.ClassSize = size; rec.Parent = token; this.ModuleBuilder.ClassLayout.AddRecord(rec); } bool hasConstructor = false; foreach (MethodBuilder mb in methods) { hasConstructor |= mb.IsSpecialName && mb.Name == ConstructorInfo.ConstructorName; mb.Bake(); } if (!hasConstructor && !IsModulePseudoType && !IsInterface && !IsValueType && !(IsAbstract && IsSealed) && Universe.AutomaticallyProvideDefaultConstructor) { ((MethodBuilder)DefineDefaultConstructor(MethodAttributes.Public).GetMethodInfo()).Bake(); } if (declarativeSecurity != null) { this.ModuleBuilder.AddDeclarativeSecurity(token, declarativeSecurity); } if (!IsModulePseudoType) { Type baseType = this.BaseType; if (baseType != null) { extends = this.ModuleBuilder.GetTypeToken(baseType).Token; } } if (interfaces != null) { foreach (Type interfaceType in interfaces) { InterfaceImplTable.Record rec = new InterfaceImplTable.Record(); rec.Class = token; rec.Interface = this.ModuleBuilder.GetTypeToken(interfaceType).Token; this.ModuleBuilder.InterfaceImpl.AddRecord(rec); } } return(new BakedType(this)); }
public Type CreateType() { if ((typeFlags & TypeFlags.Baked) != 0) { // .NET allows multiple invocations (subsequent invocations return the same baked type) throw new NotImplementedException(); } typeFlags |= TypeFlags.Baked; if (hasLayout) { ClassLayoutTable.Record rec = new ClassLayoutTable.Record(); rec.PackingSize = pack; rec.ClassSize = size; rec.Parent = token; this.ModuleBuilder.ClassLayout.AddRecord(rec); } foreach (MethodBuilder mb in methods) { mb.Bake(); } if (declarativeSecurity != null) { this.ModuleBuilder.AddDeclarativeSecurity(token, declarativeSecurity); } if (!IsModulePseudoType) { Type baseType = this.BaseType; if (baseType != null) { extends = this.ModuleBuilder.GetTypeToken(baseType).Token; } } if (interfaces != null) { foreach (Type interfaceType in interfaces) { InterfaceImplTable.Record rec = new InterfaceImplTable.Record(); rec.Class = token; rec.Interface = this.ModuleBuilder.GetTypeToken(interfaceType).Token; this.ModuleBuilder.InterfaceImpl.AddRecord(rec); } } return new BakedType(this); }
public Type CreateType() { if ((typeFlags & TypeFlags.Baked) != 0) { // .NET allows multiple invocations (subsequent invocations return the same baked type) throw new NotImplementedException(); } typeFlags |= TypeFlags.Baked; if (hasLayout) { ClassLayoutTable.Record rec = new ClassLayoutTable.Record(); rec.PackingSize = pack; rec.ClassSize = size; rec.Parent = token; this.ModuleBuilder.ClassLayout.AddRecord(rec); } bool hasConstructor = false; foreach (MethodBuilder mb in methods) { hasConstructor |= mb.IsSpecialName && mb.Name == ConstructorInfo.ConstructorName; mb.Bake(); } if (!hasConstructor && !IsModulePseudoType && !IsInterface && !IsValueType && !(IsAbstract && IsSealed)) { ((MethodBuilder)DefineDefaultConstructor(MethodAttributes.Public).GetMethodInfo()).Bake(); } if (declarativeSecurity != null) { this.ModuleBuilder.AddDeclarativeSecurity(token, declarativeSecurity); } if (!IsModulePseudoType) { Type baseType = this.BaseType; if (baseType != null) { extends = this.ModuleBuilder.GetTypeToken(baseType).Token; } } if (interfaces != null) { foreach (Type interfaceType in interfaces) { InterfaceImplTable.Record rec = new InterfaceImplTable.Record(); rec.Class = token; rec.Interface = this.ModuleBuilder.GetTypeToken(interfaceType).Token; this.ModuleBuilder.InterfaceImpl.AddRecord(rec); } } return new BakedType(this); }
public void AddInterfaceImplementation(Type interfaceType) { if (interfaces == null) { interfaces = new List<Type>(); } interfaces.Add(interfaceType); InterfaceImplTable.Record rec = new InterfaceImplTable.Record(); rec.Class = token; rec.Interface = this.ModuleBuilder.GetTypeToken(interfaceType).Token; this.ModuleBuilder.InterfaceImpl.AddRecord(rec); }