Author: marek
Date: 2007-06-11 16:40:50 -0400 (Mon, 11 Jun 2007)
New Revision: 79209

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/class.cs
   trunk/mcs/mcs/ecore.cs
   trunk/mcs/mcs/namespace.cs
   trunk/mcs/mcs/rootcontext.cs
Log:
2007-06-11  Marek Safar  <[EMAIL PROTECTED]>

        * class.cs (DefineBaseTypes): Base type can be undefined.
        
        * ecore.cs (TypeLookup): Minor refactoring.
        (DoResolveAsTypeStep): Removed redundant check.

        * namespace.cs (Lookup): Removed redundant check.
                
        * rootcontext.cs (BootstrapCorlib_ResolveType): Uses normal 
        ResolveAsTypeTerminal step.
        (BootstrapCorlib_*): Simplified.
        (PopulateCoreType): Core types can be now external.



Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-06-11 20:33:26 UTC (rev 79208)
+++ trunk/mcs/mcs/ChangeLog     2007-06-11 20:40:50 UTC (rev 79209)
@@ -1,3 +1,17 @@
+2007-06-11  Marek Safar  <[EMAIL PROTECTED]>
+
+       * class.cs (DefineBaseTypes): Base type can be undefined.
+       
+       * ecore.cs (TypeLookup): Minor refactoring.
+       (DoResolveAsTypeStep): Removed redundant check.
+
+       * namespace.cs (Lookup): Removed redundant check.
+               
+       * rootcontext.cs (BootstrapCorlib_ResolveType): Uses normal 
+       ResolveAsTypeTerminal step.
+       (BootstrapCorlib_*): Simplified.
+       (PopulateCoreType): Core types can be now external.
+
 2007-06-07  Marek Safar  <[EMAIL PROTECTED]>
 
        * anonymous.cs (VerifyExplicitParameterCompatibility): Add flag to do

Modified: trunk/mcs/mcs/class.cs
===================================================================
--- trunk/mcs/mcs/class.cs      2007-06-11 20:33:26 UTC (rev 79208)
+++ trunk/mcs/mcs/class.cs      2007-06-11 20:40:50 UTC (rev 79209)
@@ -1119,7 +1119,7 @@
                        if (!CheckRecursiveDefinition (this))
                                return false;
 
-                       if (base_type != null) {
+                       if (base_type != null && base_type.Type != null) {
                                TypeBuilder.SetParent (base_type.Type);
 
                                ObsoleteAttribute obsolete_attr = 
AttributeTester.GetObsoleteAttribute (base_type.Type);
@@ -1452,7 +1452,7 @@
 
                        InTransit = tc;
 
-                       if (base_type != null) {
+                       if (base_type != null && base_type.Type != null) {
                                Type t = TypeManager.DropGenericTypeArguments 
(base_type.Type);
                                TypeContainer ptc = 
TypeManager.LookupTypeContainer (t);
                                if ((ptc != null) && 
!ptc.CheckRecursiveDefinition (this))

Modified: trunk/mcs/mcs/ecore.cs
===================================================================
--- trunk/mcs/mcs/ecore.cs      2007-06-11 20:33:26 UTC (rev 79208)
+++ trunk/mcs/mcs/ecore.cs      2007-06-11 20:40:50 UTC (rev 79209)
@@ -2623,14 +2623,17 @@
 
                                if (type != null)
                                        return TypeManager.GetNestedType (type, 
substring);
-                               else if (resolved != null) {
+                               
+                               if (resolved != null) {
                                        resolved = (resolved as 
Namespace).Lookup (ec.DeclContainer, substring, Location.Null);
                                        if (resolved is TypeExpr)
                                                return resolved.Type;
-                                       else {
-                                               resolved.Error_UnexpectedKind 
(ec.DeclContainer, "type", loc);
-                                               return typeof (UnexpectedType);
-                                       }
+                                       
+                                       if (resolved == null)
+                                               return null;
+                                       
+                                       resolved.Error_UnexpectedKind 
(ec.DeclContainer, "type", loc);
+                                       return typeof (UnexpectedType);
                                }
                                else
                                        return null;
@@ -2642,11 +2645,11 @@
                protected override TypeExpr DoResolveAsTypeStep 
(IResolveContext ec)
                {
                        Type t = TypeLookup (ec, name);
-                       if (t == null || !ec.DeclContainer.CheckAccessLevel 
(t)) {
+                       if (t == null) {
                                NamespaceEntry.Error_NamespaceNotFound (loc, 
name);
                                return null;
                        }
-                       else if (t == typeof(UnexpectedType))
+                       if (t == typeof(UnexpectedType))
                                return null;
                        type = t;
                        return this;

Modified: trunk/mcs/mcs/namespace.cs
===================================================================
--- trunk/mcs/mcs/namespace.cs  2007-06-11 20:33:26 UTC (rev 79208)
+++ trunk/mcs/mcs/namespace.cs  2007-06-11 20:40:50 UTC (rev 79209)
@@ -463,11 +463,7 @@
                        if (namespaces.Contains (name))
                                return (Namespace) namespaces [name];
 
-                       TypeExpr te = LookupType (name, loc);
-                       if (te == null || !ds.CheckAccessLevel (te.Type))
-                               return null;
-
-                       return te;
+                       return LookupType (name, loc);
                }
 
                public void RegisterExternalExtensionMethodClass (Type type)

Modified: trunk/mcs/mcs/rootcontext.cs
===================================================================
--- trunk/mcs/mcs/rootcontext.cs        2007-06-11 20:33:26 UTC (rev 79208)
+++ trunk/mcs/mcs/rootcontext.cs        2007-06-11 20:40:50 UTC (rev 79209)
@@ -2,8 +2,10 @@
 // rootcontext.cs: keeps track of our tree representation, and assemblies 
loaded.
 //
 // Author: Miguel de Icaza ([EMAIL PROTECTED])
-//         Ravi Pratap     ([EMAIL PROTECTED])
+//            Ravi Pratap  ([EMAIL PROTECTED])
+//            Marek Safar  ([EMAIL PROTECTED])
 //
+//
 // Licensed under the terms of the GNU GPL
 //
 // (C) 2001 Ximian, Inc (http://www.ximian.com)
@@ -170,96 +172,79 @@
                                        d.DefineType ();
                }
 
-               static void Error_TypeConflict (string name, Location loc)
-               {
-                       Report.Error (
-                               520, loc, "`" + name + "' conflicts with a 
predefined type");
-               }
+               delegate bool VerifyBootstrapType (Type t);
 
-               static void Error_TypeConflict (string name)
+               static Type BootstrapCorlib_ResolveType (TypeContainer root, 
string name, VerifyBootstrapType typeVerifier)
                {
-                       Report.Error (
-                               520, "`" + name + "' conflicts with a 
predefined type");
-               }
-
-               //
-               // Resolves a single class during the corlib bootstrap process
-               //
-               static Type BootstrapCorlib_ResolveClass (TypeContainer root, 
string name)
-               {
-                       object o = root.GetDefinition (name);
-                       if (o == null){
-                               Report.Error (518, "The predefined type `" + 
name + "' is not defined or imported");
+                       TypeLookupExpression tle = new TypeLookupExpression 
(name);
+                       Report.DisableErrors ();
+                       TypeExpr te = tle.ResolveAsTypeTerminal (root, false);
+                       Report.EnableErrors ();
+                       if (te == null) {
+                               Report.Error (518, "The predefined type `{0}' 
is not defined or imported", name);
                                return null;
                        }
 
-                       if (!(o is Class)){
-                               if (o is DeclSpace){
-                                       DeclSpace d = (DeclSpace) o;
+                       Type t = te.Type;
+                       if (!typeVerifier (t)) {
+                               MemberCore mc = root.GetDefinition (name);
+                               Location loc = Location.Null;
+                               if (mc != null) {
+                                       name = mc.GetSignatureForError ();
+                                       loc = mc.Location;
+                               }
 
-                                       Error_TypeConflict (name, d.Location);
-                               } else
-                                       Error_TypeConflict (name);
-
+                               Report.Error (520, loc, "The predefined type 
`{0}' is not declared correctly", name);
                                return null;
                        }
 
-                       Type t = ((DeclSpace) o).DefineType ();
-                       if (t != null)
-                               AttributeTester.RegisterNonObsoleteType (t);
+                       AttributeTester.RegisterNonObsoleteType (t);
                        return t;
                }
+               //
+               // Resolves a single class during the corlib bootstrap process
+               //
+               static Type BootstrapCorlib_ResolveClass (TypeContainer root, 
string name)
+               {
+                       return BootstrapCorlib_ResolveType (root, name, 
IsClass);
+               }
 
+               static bool IsClass (Type t)
+               {
+                       DeclSpace ds = TypeManager.LookupDeclSpace (t);
+                       if (ds != null)
+                               return ds is Class;
+                       return t.IsClass;
+               }
+
                //
                // Resolves a struct during the corlib bootstrap process
                //
                static void BootstrapCorlib_ResolveStruct (TypeContainer root, 
string name)
                {
-                       object o = root.GetDefinition (name);
-                       if (o == null){
-                               Report.Error (518, "The predefined type `" + 
name + "' is not defined or imported");
-                               return;
-                       }
+                       BootstrapCorlib_ResolveType (root, name, IsStruct);
+               }
 
-                       if (!(o is Struct)){
-                               if (o is DeclSpace){
-                                       DeclSpace d = (DeclSpace) o;
-
-                                       Error_TypeConflict (name, d.Location);
-                               } else
-                                       Error_TypeConflict (name);
-
-                               return;
-                       }
-
-                       ((DeclSpace) o).DefineType ();
+               static bool IsStruct (Type t)
+               {
+                       DeclSpace ds = TypeManager.LookupDeclSpace (t);
+                       if (ds != null)
+                               return ds is Struct;
+                       
+                       return TypeManager.IsSubclassOf (t, 
TypeManager.value_type);                    
                }
 
                //
-               // Resolves a struct during the corlib bootstrap process
+               // Resolves an interface during the corlib bootstrap process
                //
                static void BootstrapCorlib_ResolveInterface (TypeContainer 
root, string name)
                {
-                       object o = root.GetDefinition (name);
-                       if (o == null){
-                               Report.Error (518, "The predefined type `" + 
name + "' is not defined or imported");
-                               return;
-                       }
+                       BootstrapCorlib_ResolveType (root, name, IsInterface);
+               }
 
-                       if (!(o is Interface)){
-                               if (o is DeclSpace){
-                                       DeclSpace d = (DeclSpace) o;
-
-                                       Error_TypeConflict (name, d.Location);
-                               } else
-                                       Error_TypeConflict (name);
-
-                               return;
-                       }
-
-                       Type t = ((DeclSpace) o).DefineType ();
-                       if (t != null)
-                               AttributeTester.RegisterNonObsoleteType (t);
+               static bool IsInterface (Type t)
+               {
+                       return t.IsInterface;
                }
 
                //
@@ -267,20 +252,13 @@
                //
                static void BootstrapCorlib_ResolveDelegate (TypeContainer 
root, string name)
                {
-                       object o = root.GetDefinition (name);
-                       if (o == null){
-                               Report.Error (518, "The predefined type `" + 
name + "' is not defined or imported");
-                               return;
-                       }
+                       BootstrapCorlib_ResolveType (root, name, IsDelegate);
+               }
 
-                       if (!(o is Delegate)){
-                               Error_TypeConflict (name);
-                               return;
-                       }
-
-                       ((DeclSpace) o).DefineType ();
+               static bool IsDelegate (Type t)
+               {
+                       return TypeManager.IsDelegateType (t);
                }
-               
 
                /// <summary>
                ///    Resolves the core types in the compiler when compiling 
with --nostdlib
@@ -421,13 +399,10 @@
 #if GMCS_SOURCE
                        BootstrapCorlib_ResolveStruct (root, 
"System.Nullable`1");
 #endif
-                       BootstrapCorlib_ResolveDelegate (root, 
"System.AsyncCallback");
+                       TypeManager.delegate_type = 
BootstrapCorlib_ResolveClass (root, "System.Delegate");
+                       BootstrapCorlib_ResolveClass (root, 
"System.MulticastDelegate");
 
-                       // These will be defined indirectly during the previous 
ResolveDelegate.
-                       // However make sure the rest of the checks happen.
-                       string [] delegate_types = { "System.Delegate", 
"System.MulticastDelegate" };
-                       foreach (string cname in delegate_types)
-                               BootstrapCorlib_ResolveClass (root, cname);
+                       BootstrapCorlib_ResolveDelegate (root, 
"System.AsyncCallback");
                }
                        
                // <summary>
@@ -497,6 +472,9 @@
                static public void PopulateCoreType (TypeContainer root, string 
name)
                {
                        DeclSpace ds = (DeclSpace) root.GetDefinition (name);
+                       // Core type was imported
+                       if (ds == null)
+                               return;
 
                        ds.DefineMembers ();
                        ds.Define ();

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to