2 // System.Reflection.Emit/TypeBuilder.cs
5 // Paolo Molaro (lupus@ximian.com)
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
11 using System.Reflection;
12 using System.Reflection.Emit;
13 using System.Runtime.CompilerServices;
14 using System.Runtime.InteropServices;
15 using System.Globalization;
16 using System.Collections;
17 using System.Security;
18 using System.Security.Permissions;
20 namespace System.Reflection.Emit {
21 public sealed class TypeBuilder : Type {
23 private string nspace;
25 private Type nesting_type;
26 private Type[] interfaces;
27 private MethodBuilder[] methods;
28 private ConstructorBuilder[] ctors;
29 private PropertyBuilder[] properties;
30 private FieldBuilder[] fields;
31 private EventBuilder[] events;
32 private CustomAttributeBuilder[] cattrs;
33 internal TypeBuilder[] subtypes;
34 private TypeAttributes attrs;
35 private int table_idx;
36 private ModuleBuilder pmodule;
37 private int class_size;
38 private PackingSize packing_size;
42 public const int UnspecifiedTypeSize = 0;
44 protected override TypeAttributes GetAttributeFlagsImpl () {
48 [MethodImplAttribute(MethodImplOptions.InternalCall)]
49 private extern void setup_internal_class (TypeBuilder tb);
51 [MethodImplAttribute(MethodImplOptions.InternalCall)]
52 private extern void create_internal_class (TypeBuilder tb);
54 internal TypeBuilder (ModuleBuilder mb, TypeAttributes attr) {
58 fullname = this.tname = "<Module>";
61 setup_internal_class (this);
64 internal TypeBuilder (ModuleBuilder mb, string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packing_size, int type_size, Type nesting_type) {
68 this.class_size = type_size;
69 this.packing_size = packing_size;
70 this.nesting_type = nesting_type;
71 sep_index = name.LastIndexOf('.');
72 if (sep_index != -1) {
73 this.tname = name.Substring (sep_index + 1);
74 this.nspace = name.Substring (0, sep_index);
79 if (interfaces != null) {
80 this.interfaces = new Type[interfaces.Length];
81 System.Array.Copy (interfaces, this.interfaces, interfaces.Length);
85 table_idx = mb.get_next_table_index (this, 0x02, true);
86 setup_internal_class (this);
87 fullname = GetFullName ();
90 public override Assembly Assembly {
91 get {return pmodule.Assembly;}
94 public override string AssemblyQualifiedName {
96 return fullname + ", " + Assembly.GetName().FullName;
99 public override Type BaseType {
104 public override Type DeclaringType {get {return nesting_type;}}
107 public override Type UnderlyingSystemType {
109 // This should return the type itself for non-enum types but
111 if (fields != null) {
112 foreach (FieldBuilder f in fields) {
113 if ((f.Attributes & FieldAttributes.Static) == 0)
117 throw new InvalidOperationException ("Underlying type information on enumeration is not specified.");
121 string GetFullName () {
122 if (nesting_type != null)
123 return String.Concat (nesting_type.FullName, "+", tname);
124 if ((nspace != null) && (nspace.Length > 0))
125 return String.Concat (nspace, ".", tname);
129 public override string FullName {
135 public override Guid GUID {
137 throw not_supported ();
141 public override Module Module {
142 get {return pmodule;}
144 public override string Name {
147 public override string Namespace {
150 public PackingSize PackingSize {
151 get {return packing_size;}
154 get { return class_size; }
156 public override Type ReflectedType {get {return nesting_type;}}
157 public override MemberTypes MemberType {
158 get {return MemberTypes.TypeInfo;}
162 public void AddDeclarativeSecurity( SecurityAction action, PermissionSet pset) {
163 throw new NotImplementedException ();
166 public void AddInterfaceImplementation( Type interfaceType) {
167 if (interfaceType == null)
168 throw new ArgumentNullException ("interfaceType");
170 throw not_after_created ();
172 if (interfaces != null) {
173 // Check for duplicates
174 foreach (Type t in interfaces)
175 if (t == interfaceType)
178 Type[] ifnew = new Type [interfaces.Length + 1];
179 interfaces.CopyTo (ifnew, 0);
180 ifnew [interfaces.Length] = interfaceType;
183 interfaces = new Type [1];
184 interfaces [0] = interfaceType;
189 protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder,
190 CallingConventions callConvention, Type[] types,
191 ParameterModifier[] modifiers)
196 ConstructorBuilder found = null;
199 foreach (ConstructorBuilder cb in ctors){
200 if (callConvention != CallingConventions.Any && cb.CallingConvention != callConvention)
210 throw new AmbiguousMatchException ();
213 MethodBase[] match = new MethodBase [count];
218 foreach (ConstructorInfo m in ctors) {
219 if (callConvention != CallingConventions.Any && m.CallingConvention != callConvention)
225 binder = Binder.DefaultBinder;
226 return (ConstructorInfo)binder.SelectMethod (bindingAttr, match, types, modifiers);
229 public override bool IsDefined( Type attributeType, bool inherit)
231 throw not_supported ();
234 public override object[] GetCustomAttributes(bool inherit)
236 throw not_supported ();
239 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
241 throw not_supported ();
244 public TypeBuilder DefineNestedType (string name) {
245 return DefineNestedType (name, TypeAttributes.NestedPrivate, pmodule.assemblyb.corlib_object_type, null);
248 public TypeBuilder DefineNestedType (string name, TypeAttributes attr) {
249 return DefineNestedType (name, attr, pmodule.assemblyb.corlib_object_type, null);
252 public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent) {
253 return DefineNestedType (name, attr, parent, null);
256 private TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, Type[] interfaces,
257 PackingSize packsize, int typesize)
259 check_name ("name", name);
260 // Visibility must be NestedXXX
262 if (((attrs & TypeAttributes.VisibilityMask) == TypeAttributes.Public) ||
263 ((attrs & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic))
264 throw new ArgumentException ("attr", "Bad type flags for nested type.");
266 if (interfaces != null)
267 foreach (Type iface in interfaces)
269 throw new ArgumentNullException ("interfaces");
271 TypeBuilder res = new TypeBuilder (pmodule, name, attr, parent, interfaces, packsize, typesize, this);
272 res.fullname = res.GetFullName ();
273 pmodule.RegisterTypeName (res, res.fullname);
274 if (subtypes != null) {
275 TypeBuilder[] new_types = new TypeBuilder [subtypes.Length + 1];
276 System.Array.Copy (subtypes, new_types, subtypes.Length);
277 new_types [subtypes.Length] = res;
278 subtypes = new_types;
280 subtypes = new TypeBuilder [1];
286 public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, Type[] interfaces) {
287 return DefineNestedType (name, attr, parent, interfaces, PackingSize.Unspecified, UnspecifiedTypeSize);
290 public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, int typesize) {
291 return DefineNestedType (name, attr, parent, null, PackingSize.Unspecified, typesize);
294 public TypeBuilder DefineNestedType (string name, TypeAttributes attr, Type parent, PackingSize packsize) {
295 return DefineNestedType (name, attr, parent, null, packsize, UnspecifiedTypeSize);
298 public ConstructorBuilder DefineConstructor (MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes)
301 throw not_after_created ();
302 ConstructorBuilder cb = new ConstructorBuilder (this, attributes, callingConvention, parameterTypes);
304 ConstructorBuilder[] new_ctors = new ConstructorBuilder [ctors.Length+1];
305 System.Array.Copy (ctors, new_ctors, ctors.Length);
306 new_ctors [ctors.Length] = cb;
309 ctors = new ConstructorBuilder [1];
315 public ConstructorBuilder DefineDefaultConstructor (MethodAttributes attributes)
317 ConstructorBuilder cb = DefineConstructor (attributes, CallingConventions.Standard, null);
319 ConstructorInfo parent_constructor = parent.GetConstructor (
320 BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
321 null, Type.EmptyTypes, null);
323 ILGenerator ig = cb.GetILGenerator ();
324 if (parent_constructor != null){
325 ig.Emit (OpCodes.Ldarg_0);
326 ig.Emit (OpCodes.Call, parent_constructor);
328 ig.Emit (OpCodes.Ret);
332 public MethodBuilder DefineMethod( string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) {
333 return DefineMethod (name, attributes, CallingConventions.Standard, returnType, parameterTypes);
336 private void append_method (MethodBuilder mb) {
337 if (methods != null) {
338 MethodBuilder[] new_methods = new MethodBuilder [methods.Length+1];
339 System.Array.Copy (methods, new_methods, methods.Length);
340 new_methods [methods.Length] = mb;
341 methods = new_methods;
343 methods = new MethodBuilder [1];
348 public MethodBuilder DefineMethod( string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) {
349 check_name ("name", name);
351 throw not_after_created ();
353 !((attributes & MethodAttributes.Abstract) != 0) ||
354 !((attributes & MethodAttributes.Virtual) != 0)))
355 throw new ArgumentException ("attributes", "Interface method must be abstract and virtual.");
357 if (returnType == null)
358 returnType = pmodule.assemblyb.corlib_void_type;
359 MethodBuilder res = new MethodBuilder (this, name, attributes, callingConvention, returnType, parameterTypes);
364 public MethodBuilder DefinePInvokeMethod (string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) {
365 check_name ("name", name);
366 check_name ("dllName", dllName);
367 check_name ("entryName", entryName);
368 if ((attributes & MethodAttributes.Abstract) != 0)
369 throw new ArgumentException ("attributes", "PInvoke methods must be static and native and cannot be abstract.");
371 throw new ArgumentException ("PInvoke methods cannot exist on interfaces.");
373 throw not_after_created ();
375 MethodBuilder res = new MethodBuilder (this, name, attributes, callingConvention, returnType, parameterTypes,
376 dllName, entryName, nativeCallConv, nativeCharSet);
381 public MethodBuilder DefinePInvokeMethod (string name, string dllName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) {
382 return DefinePInvokeMethod (name, dllName, name, attributes, callingConvention, returnType, parameterTypes,
383 nativeCallConv, nativeCharSet);
386 public void DefineMethodOverride( MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration) {
387 if (methodInfoBody == null)
388 throw new ArgumentNullException ("methodInfoBody");
389 if (methodInfoDeclaration == null)
390 throw new ArgumentNullException ("methodInfoDeclaration");
392 throw not_after_created ();
394 if (methodInfoBody is MethodBuilder) {
395 MethodBuilder mb = (MethodBuilder)methodInfoBody;
396 mb.set_override (methodInfoDeclaration);
400 public FieldBuilder DefineField( string fieldName, Type type, FieldAttributes attributes) {
401 check_name ("fieldName", fieldName);
402 if (type == typeof (void))
403 throw new ArgumentException ("type", "Bad field type in defining field.");
405 throw not_after_created ();
407 FieldBuilder res = new FieldBuilder (this, fieldName, type, attributes);
408 if (fields != null) {
409 FieldBuilder[] new_fields = new FieldBuilder [fields.Length+1];
410 System.Array.Copy (fields, new_fields, fields.Length);
411 new_fields [fields.Length] = res;
414 fields = new FieldBuilder [1];
416 create_internal_class (this);
421 public PropertyBuilder DefineProperty( string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) {
422 check_name ("name", name);
423 if (parameterTypes != null)
424 foreach (Type param in parameterTypes)
426 throw new ArgumentNullException ("parameterTypes");
428 throw not_after_created ();
430 PropertyBuilder res = new PropertyBuilder (this, name, attributes, returnType, parameterTypes);
432 if (properties != null) {
433 PropertyBuilder[] new_properties = new PropertyBuilder [properties.Length+1];
434 System.Array.Copy (properties, new_properties, properties.Length);
435 new_properties [properties.Length] = res;
436 properties = new_properties;
438 properties = new PropertyBuilder [1];
439 properties [0] = res;
445 public ConstructorBuilder DefineTypeInitializer() {
447 throw not_after_created ();
449 throw new NotImplementedException ();
452 [MethodImplAttribute(MethodImplOptions.InternalCall)]
453 private extern Type create_runtime_class (TypeBuilder tb);
455 public Type CreateType() {
456 /* handle nesting_type */
458 throw not_after_created ();
459 if (methods != null) {
460 foreach (MethodBuilder method in methods) {
466 // On classes, define a default constructor if not provided
468 if (!(IsInterface || IsValueType) && (ctors == null) && (tname != "<Module>"))
469 DefineDefaultConstructor (MethodAttributes.Public);
472 foreach (ConstructorBuilder ctor in ctors)
476 created = create_runtime_class (this);
482 public override ConstructorInfo[] GetConstructors (BindingFlags bindingAttr)
485 return new ConstructorInfo [0];
486 ArrayList l = new ArrayList ();
488 MethodAttributes mattrs;
490 foreach (ConstructorBuilder c in ctors) {
492 mattrs = c.Attributes;
493 if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
494 if ((bindingAttr & BindingFlags.Public) != 0)
497 if ((bindingAttr & BindingFlags.NonPublic) != 0)
503 if ((mattrs & MethodAttributes.Static) != 0) {
504 if ((bindingAttr & BindingFlags.Static) != 0)
507 if ((bindingAttr & BindingFlags.Instance) != 0)
514 ConstructorInfo[] result = new ConstructorInfo [l.Count];
519 public override Type GetElementType () {
520 throw not_supported ();
524 public override EventInfo GetEvent (string name, BindingFlags bindingAttr) {
526 throw new ArgumentNullException ("name");
528 throw new NotImplementedException ();
531 public override EventInfo[] GetEvents (BindingFlags bindingAttr) {
532 return new EventInfo [0];
536 public override FieldInfo GetField( string name, BindingFlags bindingAttr) {
538 throw new ArgumentNullException ("name");
540 throw new NotImplementedException ();
543 public override FieldInfo[] GetFields (BindingFlags bindingAttr) {
545 return new FieldInfo [0];
546 ArrayList l = new ArrayList ();
548 FieldAttributes mattrs;
550 foreach (FieldInfo c in fields) {
552 mattrs = c.Attributes;
553 if ((mattrs & FieldAttributes.FieldAccessMask) == FieldAttributes.Public) {
554 if ((bindingAttr & BindingFlags.Public) != 0)
557 if ((bindingAttr & BindingFlags.NonPublic) != 0)
563 if ((mattrs & FieldAttributes.Static) != 0) {
564 if ((bindingAttr & BindingFlags.Static) != 0)
567 if ((bindingAttr & BindingFlags.Instance) != 0)
574 FieldInfo[] result = new FieldInfo [l.Count];
580 public override Type GetInterface (string name, bool ignoreCase) {
582 throw new ArgumentNullException ("name");
584 throw new NotImplementedException ();
587 public override Type[] GetInterfaces () {
588 if (interfaces != null) {
589 Type[] ret = new Type [interfaces.Length];
590 interfaces.CopyTo (ret, 0);
593 return Type.EmptyTypes;
598 public override MemberInfo[] GetMembers( BindingFlags bindingAttr) {
600 throw new NotImplementedException ();
603 public override MethodInfo[] GetMethods (BindingFlags bindingAttr) {
605 return new MethodInfo [0];
606 ArrayList l = new ArrayList ();
608 MethodAttributes mattrs;
610 foreach (MethodInfo c in methods) {
612 mattrs = c.Attributes;
613 if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
614 if ((bindingAttr & BindingFlags.Public) != 0)
617 if ((bindingAttr & BindingFlags.NonPublic) != 0)
623 if ((mattrs & MethodAttributes.Static) != 0) {
624 if ((bindingAttr & BindingFlags.Static) != 0)
627 if ((bindingAttr & BindingFlags.Instance) != 0)
634 MethodInfo[] result = new MethodInfo [l.Count];
640 protected override MethodInfo GetMethodImpl( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
642 throw new NotImplementedException ();
646 public override Type GetNestedType( string name, BindingFlags bindingAttr) {
648 throw new ArgumentNullException ("name");
650 throw new NotImplementedException ();
653 public override Type[] GetNestedTypes (BindingFlags bindingAttr) {
655 ArrayList result = new ArrayList ();
657 if (subtypes == null)
658 return Type.EmptyTypes;
659 foreach (TypeBuilder t in subtypes) {
661 if ((t.attrs & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic) {
662 if ((bindingAttr & BindingFlags.Public) != 0)
665 if ((bindingAttr & BindingFlags.NonPublic) != 0)
672 Type[] r = new Type [result.Count];
677 public override PropertyInfo[] GetProperties( BindingFlags bindingAttr) {
678 if (properties == null)
679 return new PropertyInfo [0];
680 ArrayList l = new ArrayList ();
682 MethodAttributes mattrs;
685 foreach (PropertyInfo c in properties) {
687 accessor = c.GetGetMethod (true);
688 if (accessor == null)
689 accessor = c.GetSetMethod (true);
690 if (accessor == null)
692 mattrs = accessor.Attributes;
693 if ((mattrs & MethodAttributes.MemberAccessMask) == MethodAttributes.Public) {
694 if ((bindingAttr & BindingFlags.Public) != 0)
697 if ((bindingAttr & BindingFlags.NonPublic) != 0)
703 if ((mattrs & MethodAttributes.Static) != 0) {
704 if ((bindingAttr & BindingFlags.Static) != 0)
707 if ((bindingAttr & BindingFlags.Instance) != 0)
714 PropertyInfo[] result = new PropertyInfo [l.Count];
720 protected override PropertyInfo GetPropertyImpl( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
722 throw new NotImplementedException ();
725 protected override bool HasElementTypeImpl () {
726 // According to the MSDN docs, this is supported for TypeBuilders,
727 // but in reality, it is not
728 throw not_supported ();
729 // return IsArrayImpl() || IsByRefImpl() || IsPointerImpl ();
732 public override object InvokeMember( string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) {
733 throw not_supported ();
736 protected override bool IsArrayImpl () {
737 return type_is_subtype_of (this, typeof (System.Array), false);
739 protected override bool IsByRefImpl () {
743 protected override bool IsCOMObjectImpl () {
746 protected override bool IsPointerImpl () {
750 protected override bool IsPrimitiveImpl () {
754 protected override bool IsValueTypeImpl () {
755 return ((type_is_subtype_of (this, pmodule.assemblyb.corlib_value_type, false) || type_is_subtype_of (this, typeof(System.ValueType), false)) &&
756 this != pmodule.assemblyb.corlib_value_type &&
757 this != pmodule.assemblyb.corlib_enum_type);
760 public override RuntimeTypeHandle TypeHandle {
762 throw not_supported ();
766 public void SetCustomAttribute( CustomAttributeBuilder customBuilder) {
767 if (customBuilder == null)
768 throw new ArgumentNullException ("customBuilder");
770 string attrname = customBuilder.Ctor.ReflectedType.FullName;
771 if (attrname == "System.Runtime.InteropServices.StructLayoutAttribute") {
772 byte[] data = customBuilder.Data;
773 int layout_kind; /* the (stupid) ctor takes a short or an int ... */
774 layout_kind = (int)data [2];
775 layout_kind |= ((int)data [3]) << 8;
776 attrs &= ~TypeAttributes.LayoutMask;
777 switch ((LayoutKind)layout_kind) {
778 case LayoutKind.Auto:
779 attrs |= TypeAttributes.AutoLayout;
781 case LayoutKind.Explicit:
782 attrs |= TypeAttributes.ExplicitLayout;
784 case LayoutKind.Sequential:
785 attrs |= TypeAttributes.SequentialLayout;
788 // we should ignore it since it can be any value anyway...
789 throw new Exception ("Error in customattr");
791 string first_type_name = customBuilder.Ctor.GetParameters()[0].ParameterType.FullName;
793 if (first_type_name == "System.Int16")
795 int nnamed = (int)data [pos++];
796 nnamed |= ((int)data [pos++]) << 8;
797 for (int i = 0; i < nnamed; ++i) {
798 byte named_type = data [pos++];
799 byte type = data [pos++];
800 int len = CustomAttributeBuilder.decode_len (data, pos, out pos);
801 string named_name = CustomAttributeBuilder.string_from_bytes (data, pos, len);
803 /* all the fields are integers in StructLayout */
804 int value = (int)data [pos++];
805 value |= ((int)data [pos++]) << 8;
806 value |= ((int)data [pos++]) << 16;
807 value |= ((int)data [pos++]) << 24;
808 switch (named_name) {
810 switch ((CharSet)value) {
814 case CharSet.Unicode:
815 attrs |= TypeAttributes.UnicodeClass;
818 attrs |= TypeAttributes.AutoClass;
821 break; // error out...
825 packing_size = (PackingSize)value;
831 break; // error out...
835 } else if (attrname == "System.SerializableAttribute") {
836 attrs |= TypeAttributes.Serializable;
839 if (cattrs != null) {
840 CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
841 cattrs.CopyTo (new_array, 0);
842 new_array [cattrs.Length] = customBuilder;
845 cattrs = new CustomAttributeBuilder [1];
846 cattrs [0] = customBuilder;
849 public void SetCustomAttribute( ConstructorInfo con, byte[] binaryAttribute) {
850 SetCustomAttribute (new CustomAttributeBuilder (con, binaryAttribute));
853 public EventBuilder DefineEvent( string name, EventAttributes attributes, Type eventtype) {
854 check_name ("name", name);
855 if (eventtype == null)
856 throw new ArgumentNullException ("eventtype");
858 throw not_after_created ();
860 EventBuilder res = new EventBuilder (this, name, attributes, eventtype);
861 if (events != null) {
862 EventBuilder[] new_events = new EventBuilder [events.Length+1];
863 System.Array.Copy (events, new_events, events.Length);
864 new_events [events.Length] = res;
867 events = new EventBuilder [1];
873 static int InitializedDataCount = 0;
875 public FieldBuilder DefineInitializedData( string name, byte[] data, FieldAttributes attributes) {
876 check_name ("name", name);
878 throw new ArgumentNullException ("data");
879 if ((data.Length == 0) || (data.Length > 0x3f0000))
880 throw new ArgumentException ("data", "Data size must be > 0 and < 0x3f0000");
882 throw not_after_created ();
884 TypeBuilder datablobtype = DefineNestedType ("$ArrayType$"+InitializedDataCount.ToString(),
885 TypeAttributes.NestedPrivate|TypeAttributes.ExplicitLayout|TypeAttributes.Sealed,
886 pmodule.assemblyb.corlib_value_type, null, PackingSize.Size1, data.Length);
887 datablobtype.CreateType ();
888 FieldBuilder res = DefineField (name, datablobtype, attributes|FieldAttributes.Assembly|FieldAttributes.Static|FieldAttributes.HasFieldRVA);
889 res.SetRVAData (data);
890 InitializedDataCount++;
895 public FieldBuilder DefineUninitializedData( string name, int size, FieldAttributes attributes) {
896 check_name ("name", name);
897 if ((size <= 0) || (size > 0x3f0000))
898 throw new ArgumentException ("data", "Data size must be > 0 and < 0x3f0000");
900 throw not_after_created ();
902 throw new NotImplementedException ();
905 public TypeToken TypeToken {
907 return new TypeToken (0x02000000 | table_idx);
910 public void SetParent (Type parentType) {
911 if (parentType == null)
912 throw new ArgumentNullException ("parentType");
914 throw not_after_created ();
918 internal int get_next_table_index (object obj, int table, bool inc) {
919 return pmodule.get_next_table_index (obj, table, inc);
922 public override InterfaceMapping GetInterfaceMap (Type interfaceType)
925 throw new NotSupportedException ("This method is not implemented for incomplete types.");
927 return created.GetInterfaceMap (interfaceType);
930 internal bool is_created {
932 return created != null;
936 private Exception not_supported ()
938 return new NotSupportedException ("The invoked member is not supported in a dynamic module.");
941 private Exception not_after_created ()
943 return new InvalidOperationException ("Unable to change after type has been created.");
946 private void check_name (string argName, string name)
949 throw new ArgumentNullException (argName);
951 throw new ArgumentException (argName, "Empty name is not legal.");
952 if (name.IndexOf ((char)0) != -1)
953 throw new ArgumentException (argName, "Illegal name.");