Browse Source

2009-12-08 Rodrigo Kumpera <[email protected]>

	* Type.cs: Add virtual property IsCompilerContext to cleanup
	compiler context resolution across SRE.

2009-12-08 Rodrigo Kumpera  <[email protected]>

	* MonoGenericClass.cs: Implement IsCompilerContext property and replace
	all checks to use it.

2009-12-08 Rodrigo Kumpera  <[email protected]>

	* DerivedTypes.cs: Implement IsCompilerContext property and replace
	all checks to use it.

	* EnumBuilder.cs: Ditto.

	* GenericTypeParameterBuilder.cs: Ditto.

	* TypeBuilder.cs: Ditto.

	* FieldOnTypeBuilderInst.cs: Replace ad-hoc check for compiler context
	with proper call to generic instance type.

	* MethodOnTypeBuilderInst.cs: Ditto.

	* ConstructorOnTypeBuilderInst.cs: Ditto.

svn path=/trunk/mcs/; revision=147849
Rodrigo Kumpera 16 years ago
parent
commit
e1d99a0249

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

@@ -1,3 +1,21 @@
+2009-12-08 Rodrigo Kumpera  <[email protected]>
+
+	* DerivedTypes.cs: Implement IsCompilerContext property and replace
+	all checks to use it.
+
+	* EnumBuilder.cs: Ditto.
+
+	* GenericTypeParameterBuilder.cs: Ditto.
+
+	* TypeBuilder.cs: Ditto.
+
+	* FieldOnTypeBuilderInst.cs: Replace ad-hoc check for compiler context
+	with proper call to generic instance type.
+
+	* MethodOnTypeBuilderInst.cs: Ditto.
+
+	* ConstructorOnTypeBuilderInst.cs: Ditto.
+
 2009-12-04 Rodrigo Kumpera  <[email protected]>
 
 	* MethodBuilder.cs (MakeGenericMethod): Don't rely on the runtime to

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

@@ -97,7 +97,7 @@ namespace System.Reflection.Emit
 
 		public override ParameterInfo[] GetParameters ()
 		{
-			if (!((ModuleBuilder)cb.Module).assemblyb.IsCompilerContext && !instantiation.generic_type.is_created)
+			if (!instantiation.IsCompilerContext && !instantiation.generic_type.is_created)
 				throw new NotSupportedException ();
 
 			ParameterInfo [] res = new ParameterInfo [cb.parameters.Length];
@@ -110,7 +110,7 @@ namespace System.Reflection.Emit
 
 		public override int MetadataToken {
 			get {
-				if (!((ModuleBuilder)cb.Module).assemblyb.IsCompilerContext)
+				if (!instantiation.IsCompilerContext)
 					return base.MetadataToken;
 				return cb.MetadataToken;
 			}

+ 7 - 1
mcs/class/corlib/System.Reflection.Emit/DerivedTypes.cs

@@ -58,6 +58,12 @@ namespace System.Reflection.Emit
 
 		internal abstract String FormatName (string elementName);
 
+		internal override bool IsCompilerContext {
+			get {
+				return elementType.IsCompilerContext;
+			}
+		}
+
 		public override Type GetInterface (string name, bool ignoreCase)
 		{
 			throw new NotSupportedException ();
@@ -342,7 +348,7 @@ namespace System.Reflection.Emit
 
 		protected override TypeAttributes GetAttributeFlagsImpl ()
 		{
-			if (((ModuleBuilder)elementType.Module).assemblyb.IsCompilerContext)
+			if (IsCompilerContext)
 				return (elementType.Attributes & TypeAttributes.VisibilityMask) | TypeAttributes.Sealed | TypeAttributes.Serializable;
 			return elementType.Attributes;
 		}

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

@@ -62,6 +62,12 @@ namespace System.Reflection.Emit {
 			return _tb;
 		}
 
+		internal override bool IsCompilerContext {
+			get {
+				return _tb.IsCompilerContext;
+			}
+		}
+
 		public override Assembly Assembly {
 			get {
 				return _tb.Assembly;

+ 3 - 3
mcs/class/corlib/System.Reflection.Emit/FieldOnTypeBuilderInst.cs

@@ -84,7 +84,7 @@ namespace System.Reflection.Emit
 
 		public override string ToString ()
 		{
-			if (!((ModuleBuilder)instantiation.generic_type.Module).assemblyb.IsCompilerContext)
+			if (!instantiation.IsCompilerContext)
 				return fb.FieldType.ToString () + " " + Name;
 			return FieldType.ToString () + " " + Name;
 		}
@@ -106,7 +106,7 @@ namespace System.Reflection.Emit
 
 		public override int MetadataToken {
 			get {
-				if (!((ModuleBuilder)instantiation.generic_type.Module).assemblyb.IsCompilerContext)
+				if (!instantiation.IsCompilerContext)
 					throw new InvalidOperationException ();
 				return fb.MetadataToken;
 			} 
@@ -114,7 +114,7 @@ namespace System.Reflection.Emit
 
 		public override Type FieldType {
 			get {
-				if (!((ModuleBuilder)instantiation.generic_type.Module).assemblyb.IsCompilerContext)
+				if (!instantiation.IsCompilerContext)
 					throw new NotSupportedException ();
 				return instantiation.InflateType (fb.FieldType);
 			}

+ 11 - 4
mcs/class/corlib/System.Reflection.Emit/GenericTypeParameterBuilder.cs

@@ -81,13 +81,20 @@ namespace System.Reflection.Emit
 			initialize ();
 		}
 
+
+		internal override bool IsCompilerContext {
+			get {
+				return tbuilder.IsCompilerContext;
+			}
+		}
+
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
 		private extern void initialize ();
 
 		[ComVisible (true)]
 		public override bool IsSubclassOf (Type c)
 		{
-			if (!((ModuleBuilder)tbuilder.Module).assemblyb.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw not_supported ();
 			if (BaseType == null)
 				return false;
@@ -100,7 +107,7 @@ namespace System.Reflection.Emit
 #if NET_4_0
 			return TypeAttributes.Public;
 #else
-			if (((ModuleBuilder)tbuilder.Module).assemblyb.IsCompilerContext)
+			if (IsCompilerContext)
 				return TypeAttributes.Public;
 			throw not_supported ();
 #endif
@@ -359,7 +366,7 @@ namespace System.Reflection.Emit
 
 		public override GenericParameterAttributes GenericParameterAttributes {
 			get {
-				if (((ModuleBuilder)tbuilder.Module).assemblyb.IsCompilerContext)
+				if (IsCompilerContext)
 					return attrs;
 				throw new NotSupportedException ();
 			}
@@ -371,7 +378,7 @@ namespace System.Reflection.Emit
 
 		public override Type[] GetGenericParameterConstraints ()
 		{
-			if (!((ModuleBuilder)tbuilder.Module).assemblyb.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new InvalidOperationException ();
 			if (base_type == null) {
 				if (iface_constraints != null)

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

@@ -78,7 +78,7 @@ namespace System.Reflection.Emit
 		}
 
 		internal bool IsCompilerContext {
-			get { return ((ModuleBuilder)base_method.Module).assemblyb.IsCompilerContext; }
+			get { return instantiation.IsCompilerContext; }
 		}
 
 		//

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

@@ -1610,7 +1610,7 @@ namespace System.Reflection.Emit
 			return created.GetInterfaceMap (interfaceType);
 		}
 
-		internal bool IsCompilerContext {
+		internal override bool IsCompilerContext {
 			get {
 				return pmodule.assemblyb.IsCompilerContext;
 			}

+ 5 - 0
mcs/class/corlib/System.Reflection/ChangeLog

@@ -1,3 +1,8 @@
+2009-12-08 Rodrigo Kumpera  <[email protected]>
+
+	* MonoGenericClass.cs: Implement IsCompilerContext property and replace
+	all checks to use it.
+
 2009-12-04 Rodrigo Kumpera  <[email protected]>
 
 	* MonoGenericClass.cs (InflateType): Add a type argument parameter and

+ 14 - 8
mcs/class/corlib/System.Reflection/MonoGenericClass.cs

@@ -73,6 +73,12 @@ namespace System.Reflection
 			this.type_arguments = args;
 		}
 
+		internal override bool IsCompilerContext {
+			get {
+				return generic_type.IsCompilerContext;
+			}
+		}
+
 		[MethodImplAttribute(MethodImplOptions.InternalCall)]
 		extern void initialize (MethodInfo[] methods, ConstructorInfo[] ctors, FieldInfo[] fields, PropertyInfo[] properties, EventInfo[] events);
 
@@ -168,7 +174,7 @@ namespace System.Reflection
 
 		public override Type[] GetInterfaces ()
 		{
-			if (!generic_type.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new NotSupportedException ();
 			return GetInterfacesInternal ();
 		}
@@ -225,7 +231,7 @@ namespace System.Reflection
 		
 		public override MethodInfo[] GetMethods (BindingFlags bf)
 		{
-			if (!generic_type.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new NotSupportedException ();
 
 			ArrayList l = new ArrayList ();
@@ -307,7 +313,7 @@ namespace System.Reflection
 
 		public override ConstructorInfo[] GetConstructors (BindingFlags bf)
 		{
-			if (!generic_type.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new NotSupportedException ();
 
 			ArrayList l = new ArrayList ();
@@ -380,7 +386,7 @@ namespace System.Reflection
 
 		public override FieldInfo[] GetFields (BindingFlags bf)
 		{
-			if (!generic_type.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new NotSupportedException ();
 
 			ArrayList l = new ArrayList ();
@@ -453,7 +459,7 @@ namespace System.Reflection
 
 		public override PropertyInfo[] GetProperties (BindingFlags bf)
 		{
-			if (!generic_type.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new NotSupportedException ();
 
 			ArrayList l = new ArrayList ();
@@ -529,7 +535,7 @@ namespace System.Reflection
 
 		public override EventInfo[] GetEvents (BindingFlags bf)
 		{
-			if (!generic_type.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new NotSupportedException ();
 
 			ArrayList l = new ArrayList ();
@@ -659,7 +665,7 @@ namespace System.Reflection
 		string format_name (bool full_name, bool assembly_qualified)
 		{
 			StringBuilder sb = new StringBuilder (generic_type.FullName);
-			bool compiler_ctx = generic_type.IsCompilerContext;
+			bool compiler_ctx = IsCompilerContext;
 
 			sb.Append ("[");
 			for (int i = 0; i < type_arguments.Length; ++i) {
@@ -758,7 +764,7 @@ namespace System.Reflection
 
 		public override EventInfo GetEvent (string name, BindingFlags bindingAttr)
 		{
-			if (!generic_type.IsCompilerContext)
+			if (!IsCompilerContext)
 				throw new NotSupportedException ();
 			foreach (var evt in GetEvents (bindingAttr)) {
 				if (evt.Name == name)

+ 5 - 0
mcs/class/corlib/System/ChangeLog

@@ -1,3 +1,8 @@
+2009-12-08 Rodrigo Kumpera  <[email protected]>
+
+	* Type.cs: Add virtual property IsCompilerContext to cleanup
+	compiler context resolution across SRE.
+
 2009-12-05  Mark Probst  <[email protected]>
 
 	* String.cs: A new LOS_limit variable which gives the maximum

+ 6 - 0
mcs/class/corlib/System/Type.cs

@@ -1142,6 +1142,12 @@ namespace System {
 			return FullName;
 		}
 
+		internal virtual bool IsCompilerContext {
+			get {
+					return false;
+			}
+		}
+
 		internal bool IsSystemType {
 			get {
 				return _impl.Value != IntPtr.Zero;