Browse Source

2002-03-25 Miguel de Icaza <[email protected]>

	* IntPtr.cs: Temporary work-around until I fix the assembly
	attributes bug.

	* String.cs (System): Removed enumeration, because it is pretty
	hard to support enumerations in /nostdlib mode for the core types.

2002-03-25  Miguel de Icaza  <[email protected]>

	* interface.cs: Implement the same search algorithm for types in
	the interface code.

	* delegate.cs: Do not allow multiple definition.

svn path=/trunk/mcs/; revision=3335
Miguel de Icaza 24 years ago
parent
commit
fb55f6cfdf

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

@@ -1,3 +1,11 @@
+2002-03-25  Miguel de Icaza  <[email protected]>
+
+	* IntPtr.cs: Temporary work-around until I fix the assembly
+	attributes bug.
+
+	* String.cs (System): Removed enumeration, because it is pretty
+	hard to support enumerations in /nostdlib mode for the core types.
+
 Tue Mar 19 18:18:49 CET 2002 Paolo Molaro <[email protected]>
 
 	* Array.cs: move error handling in the catch block.

+ 3 - 0
mcs/class/corlib/System/IntPtr.cs

@@ -21,9 +21,12 @@
 using System;
 using System.Runtime.Serialization;
 
+#if __MonoCS__
+#else
 [
     assembly: System.CLSCompliant(true)
 ]
+#endif
 
 namespace System {
 

+ 9 - 11
mcs/class/corlib/System/String.cs

@@ -269,11 +269,9 @@ namespace System {
 			return null;
 		}
 
-		internal enum _StringCompareMode {
-			CompareDirect,
-			CompareCaseInsensitive,
-			CompareOrdinal
-		};
+		const int StringCompareModeDirect = 0;
+		const int StringCompareModeCaseSensitive = 1;
+		const int StringCompareModeOrdinal = 2;
 
 		internal static int _CompareGetLength (string strA, string strB)
 		{
@@ -289,7 +287,7 @@ namespace System {
 			int result = 0;
 
 			switch (mode) {
-			case _StringCompareMode.CompareDirect:
+			case StringCompareModeDirect:
 				// FIXME: We should do a culture based comparision here,
 				//        but for the moment let's do it by hand.
 				//        In the microsoft runtime, uppercase letters
@@ -301,10 +299,10 @@ namespace System {
 				return -1;
 				result = (int) (chrA - chrB);
 				break;
-			case _StringCompareMode.CompareCaseInsensitive:
+			case StringCompareModeCaseInsensitive:
 				result = (int) (Char.ToLower (chrA) - Char.ToLower (chrB));
 				break;
-			case _StringCompareMode.CompareOrdinal:
+			case StringCompareModeOrdinal:
 				result = (int) (tolowerordinal (chrA) - tolowerordinal (chrB));
 				break;
 			}
@@ -397,8 +395,8 @@ namespace System {
 		{
 			_StringCompareMode mode;
 
-			mode = ignoreCase ? _StringCompareMode.CompareCaseInsensitive :
-				_StringCompareMode.CompareDirect;
+			mode = ignoreCase ? StringCompareModeCaseInsensitive :
+				StringCompareModeDirect;
 
 			return _Compare (strA, indexA, strB, indexB, length, culture, mode);
 		}
@@ -412,7 +410,7 @@ namespace System {
 						  int length)
 		{
 			return _Compare (strA, indexA, strB, indexB, length, null,
-					 _StringCompareMode.CompareOrdinal);
+					 StringCompareModeOrdinal);
 		}
 
 		public int CompareTo (object obj)

+ 3 - 1
mcs/errors/errors.txt

@@ -48,4 +48,6 @@ numbers to match the Microsoft numbers:
 
 -17     A type has already been defined (try --nostdlib)
 
--18	Do not know how to generate debugging information for this platform.
+-18	Do not know how to generate debugging information for this platform.
+
+-19     Can not find required utility function in the core libraries.

+ 5 - 0
mcs/mcs/ChangeLog

@@ -1,5 +1,10 @@
 2002-03-25  Miguel de Icaza  <[email protected]>
 
+	* interface.cs: Implement the same search algorithm for types in
+	the interface code.
+
+	* delegate.cs: Do not allow multiple definition.
+
 	* Recovered ChangeLog that got accidentally amputated
 
 	* interface.cs (Interface.DefineInterface): Prevent from double definitions.

+ 8 - 0
mcs/mcs/TODO

@@ -272,6 +272,14 @@ OPTIMIZATIONS
 	If the types are the same, there is no need to compute the unionset,
  	we can just use the list from one of the types.
 
+* Factor all the `DefineBlah' in Classes, Interfaces, Delegates, Enums into the
+  same thing, use an abstract interface.
+
+* Factor all the FindMembers in all the FindMembers providers.
+
+* Factor the lookup code for class declarations an interfaces
+  (interface.cs:GetInterfaceByName)
+
 RECOMMENDATIONS
 ---------------
 

+ 5 - 1
mcs/mcs/delegate.cs

@@ -58,8 +58,12 @@ namespace Mono.CSharp {
 		public void DefineDelegate (object parent_builder)
 		{
 			TypeAttributes attr;
-			string name = Name.Substring (1 + Name.LastIndexOf ('.'));
+
+			if (TypeBuilder != null)
+				return;
 			
+			string name = Name.Substring (1 + Name.LastIndexOf ('.'));
+
 			if (parent_builder is ModuleBuilder) {
 				ModuleBuilder builder = (ModuleBuilder) parent_builder;
 				attr = TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Sealed;

+ 93 - 23
mcs/mcs/interface.cs

@@ -553,10 +553,14 @@ namespace Mono.CSharp {
 		// is `name'.
 		//
 		
-		Type GetInterfaceTypeByName (object builder, string name)
+		Type LookupInterfaceByName (object builder, string ns, string name, out bool error)
 		{
 			Interface parent;
-			Type t = RootContext.LookupType (this, name, false, Location);
+			Type t;
+
+			error = false;
+			name = TypeContainer.MakeFQN (ns, name);
+			t = TypeManager.LookupType (name);
 			
 			if (t != null) {
 				if (t.IsInterface)
@@ -571,6 +575,7 @@ namespace Mono.CSharp {
 				else
 					cause = "Should not happen.";
 
+				error = true;
 				Report.Error (527, Location, "`"+name+"' " + cause +
 					      ", need an interface instead");
 				
@@ -579,38 +584,103 @@ namespace Mono.CSharp {
 
 			Tree tree = RootContext.Tree;
 			parent = (Interface) tree.Interfaces [name];
-			if (parent == null){
-				string cause = null;
-				Hashtable container;
-				
-				container = tree.Classes;
-				if (container != null && container [name] != null)
-					cause = "is a class";
-				else {
-					container = tree.Structs;
-					
-					if (container != null && container [name] != null)
-						cause = "is a struct";
-				}
-
-				if (cause == null){
-					Report.Error (246, Location, "Can not find type `"+name+"'");
-				} else {
-					Report.Error (527, Location, "`"+name+"' " + cause +
-						      ", need an interface instead");
-				}
+			if (parent == null)
 				return null;
-			}
 			
 			t = parent.DefineInterface (builder);
 			if (t == null){
 				Report.Error (529,
 					      "Inherited interface `"+name+"' is circular");
+				error = true;
 				return null;
 			}
 
 			return t;
 		}
+
+		Type GetInterfaceTypeByName (object builder, string name)
+		{
+			//
+			// For the case the type we are looking for is nested within this one
+			// or is in any base class
+			//
+			DeclSpace containing_ds = this;
+			bool error = false;
+			Type t;
+			
+			while (containing_ds != null){
+				Type current_type = containing_ds.TypeBuilder;
+
+				while (current_type != null) {
+					string pre = current_type.FullName;
+					
+					t = LookupInterfaceByName (builder, pre, name, out error);
+					if (error)
+						return null;
+				
+					if (t != null) 
+						return t;
+
+					current_type = current_type.BaseType;
+				}
+				containing_ds = containing_ds.Parent;
+			}
+
+			//
+			// Attempt to lookup the class on our namespace and all it's implicit parents
+			//
+			for (string ns = Namespace.Name; ns != null; ns = RootContext.ImplicitParent (ns)){
+				t = LookupInterfaceByName (builder, ns, name, out error);
+				if (error)
+					return null;
+				if (t != null)
+					return t;
+			}
+
+			//
+			// Attempt to do a direct unqualified lookup
+			//
+			t = LookupInterfaceByName (builder, "", name, out error);
+			if (error)
+				return null;
+			
+			if (t != null)
+				return t;
+			
+			//
+			// Attempt to lookup the class on any of the `using'
+			// namespaces
+			//
+
+			for (Namespace ns = Namespace; ns != null; ns = ns.Parent){
+				t = LookupInterfaceByName (builder, ns.Name, name, out error);
+				if (error)
+					return null;
+
+				if (t != null)
+					return t;
+
+				//
+				// Now check the using clause list
+				//
+				ArrayList using_list = ns.UsingTable;
+				
+				if (using_list == null)
+					continue;
+
+				foreach (string n in using_list){
+					t = LookupInterfaceByName (builder, n, name, out error);
+					if (error)
+						return null;
+
+					if (t != null)
+						return t;
+				}
+			}
+
+			Report.Error (246, Location, "Can not find type `"+name+"'");
+			return null;
+		}
 		
 		//
 		// Returns the list of interfaces that this interface implements