فهرست منبع

Thu Feb 28 19:15:10 CET 2002 Paolo Molaro <[email protected]>

	* AssemblyBuilder.cs: call into the runtime to init some basic
	assembly stuff. Reserve slot 1 of typedef table for .<Module>.
	* ModuleBuilder.cs: call into the runtime if we need to create a
	modief type, such as arrays, byref etc.
	* TypeBuilder.cs: call into the runtime to create the MonoClass
	representation for the type. Throw exceptions with not implemented
	stuff.

svn path=/trunk/mcs/; revision=2770
Paolo Molaro 24 سال پیش
والد
کامیت
02af74bbd1

+ 6 - 0
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs

@@ -26,8 +26,12 @@ namespace System.Reflection.Emit {
 		private CustomAttributeBuilder[] cattrs;
 		private int[] table_indexes;
 
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		private static extern void basic_init (AssemblyBuilder ab);
+		
 		internal AssemblyBuilder (AssemblyName n, AssemblyBuilderAccess access) {
 			name = n.Name;
+			basic_init (this);
 		}
 
 		internal int get_next_table_index (int table, bool inc) {
@@ -35,6 +39,8 @@ namespace System.Reflection.Emit {
 				table_indexes = new int [64];
 				for (int i=0; i < 64; ++i)
 					table_indexes [i] = 1;
+				/* allow room for .<Module> in TypeDef table */
+				table_indexes [0x02] = 2;
 			}
 			// Console.WriteLine ("getindex for table "+table.ToString()+" got "+table_indexes [table].ToString());
 			if (inc)

+ 10 - 0
mcs/class/corlib/System.Reflection.Emit/ChangeLog

@@ -1,4 +1,14 @@
 
+Thu Feb 28 19:15:10 CET 2002 Paolo Molaro <[email protected]>
+
+	* AssemblyBuilder.cs: call into the runtime to init some basic
+	assembly stuff. Reserve slot 1 of typedef table for .<Module>.
+	* ModuleBuilder.cs: call into the runtime if we need to create a
+	modief type, such as arrays, byref etc.
+	* TypeBuilder.cs: call into the runtime to create the MonoClass
+	representation for the type. Throw exceptions with not implemented
+	stuff.
+
 Wed Feb 27 18:48:47 CET 2002 Paolo Molaro <[email protected]>
 
 	* ILGenerator.cs: fix nested exception blocks.

+ 24 - 1
mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs

@@ -11,6 +11,7 @@
 using System;
 using System.Reflection;
 using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
 
 namespace System.Reflection.Emit {
 	public class ModuleBuilder : Module {
@@ -94,16 +95,36 @@ namespace System.Reflection.Emit {
 			}
 			return null;
 		}
+
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		private static extern Type create_modified_type (TypeBuilder tb, int arrayrank, bool isbyref);
 		
 		public override Type GetType( string className, bool throwOnError, bool ignoreCase) {
 			int subt;
+			bool isbyref;
+			int arrayrank = 0;
 			TypeBuilder result = null;
 
 			if (types == null && throwOnError)
 				throw new TypeLoadException (className);
+
+			subt = className.IndexOf ('&');
+			if (subt >= 0) {
+				isbyref = true;
+				className = className.Substring (0, subt);
+			} else
+				isbyref = false;
+			subt = className.IndexOf ('[');
+			if (subt >= 0) {
+				arrayrank = 1;
+				// FIXME: support different ranks..
+				className = className.Substring (0, subt);
+			}
+			
 			subt = className.IndexOf ('+');
 			if (subt < 0) {
-				result = search_in_array (types, className, ignoreCase);
+				if (types != null)
+					result = search_in_array (types, className, ignoreCase);
 			} else {
 				string pname, rname;
 				pname = className.Substring (0, subt);
@@ -116,6 +137,8 @@ namespace System.Reflection.Emit {
 			}
 			if ((result == null) && throwOnError)
 				throw new TypeLoadException (className);
+			if (result != null && (isbyref || arrayrank > 0))
+				return create_modified_type (result, arrayrank, isbyref);
 			return result;
 		}
 

+ 29 - 2
mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs

@@ -13,6 +13,8 @@ using System.Reflection.Emit;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Globalization;
+using System.Security;
+using System.Security.Permissions;
 
 namespace System.Reflection.Emit {
 	public sealed class TypeBuilder : Type {
@@ -38,6 +40,9 @@ namespace System.Reflection.Emit {
 			return attrs;
 		}
 		
+		[MethodImplAttribute(MethodImplOptions.InternalCall)]
+		private extern void setup_internal_class (TypeBuilder tb);
+		
 		internal TypeBuilder (ModuleBuilder mb, string name, TypeAttributes attr, Type parent, Type[] interfaces) {
 			int sep_index;
 			this.parent = parent;
@@ -58,9 +63,12 @@ namespace System.Reflection.Emit {
 			pmodule = mb;
 			// skip .<Module> ?
 			table_idx = mb.get_next_table_index (0x02, true);
+			setup_internal_class (this);
 		}
 
-		public override Assembly Assembly {get {return null;}}
+		public override Assembly Assembly {
+			get {return pmodule.Assembly;}
+		}
 		public override string AssemblyQualifiedName {get {return null;}}
 		public override Type BaseType {get {return parent;}}
 		public override Type DeclaringType {get {return null;}}
@@ -97,6 +105,14 @@ namespace System.Reflection.Emit {
 			get {return MemberTypes.TypeInfo;}
 		}
 
+		public void AddDeclarativeSecurity( SecurityAction action, PermissionSet pset) {
+			throw new NotImplementedException ();
+		}
+
+		public void AddInterfaceImplementation( Type interfaceType) {
+			throw new NotImplementedException ();
+		}
+
 		protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
 			throw new NotImplementedException ();
 		}
@@ -239,6 +255,10 @@ namespace System.Reflection.Emit {
 			return res;
 		}
 
+		public ConstructorBuilder DefineTypeInitializer() {
+			throw new NotImplementedException ();
+		}
+
 		public Type CreateType() {
 			if (methods != null) {
 				foreach (MethodBuilder method in methods) {
@@ -308,26 +328,31 @@ namespace System.Reflection.Emit {
 
 		protected override MethodInfo GetMethodImpl( string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) {
 			// FIXME
+			throw new NotImplementedException ();
 			return null;
 		}
 		
 		public override Type GetNestedType( string name, BindingFlags bindingAttr) {
 			// FIXME
+			throw new NotImplementedException ();
 			return null;
 		}
 
 		public override Type[] GetNestedTypes (BindingFlags bindingAttr) {
 			// FIXME
+			throw new NotImplementedException ();
 			return null;
 		}
 
 		public override PropertyInfo[] GetProperties( BindingFlags bindingAttr) {
 			// FIXME
+			throw new NotImplementedException ();
 			return null;
 		}
 		
 		protected override PropertyInfo GetPropertyImpl( string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) {
 			// FIXME
+			throw new NotImplementedException ();
 			return null;
 		}
 
@@ -337,6 +362,7 @@ namespace System.Reflection.Emit {
 
 		public override object InvokeMember( string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) {
 			// FIXME
+			throw new NotImplementedException ();
 			return null;
 		}
 
@@ -382,7 +408,7 @@ namespace System.Reflection.Emit {
 		}
 
 		public EventBuilder DefineEvent( string name, EventAttributes attributes, Type eventtype) {
-			return null;
+			throw new NotImplementedException ();
 		}
 
 		static int InitializedDataCount = 0;
@@ -401,6 +427,7 @@ namespace System.Reflection.Emit {
 		}
 
 		public FieldBuilder DefineUninitializedData( string name, int size, FieldAttributes attributes) {
+			throw new NotImplementedException ();
 			return null;
 		}