Author: martin
Date: 2005-08-31 10:45:03 -0400 (Wed, 31 Aug 2005)
New Revision: 49189

Modified:
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/codegen.cs
   trunk/mcs/gmcs/namespace.cs
   trunk/mcs/gmcs/typemanager.cs
Log:
**** Merged 47338 from MCS ****

Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-08-31 14:43:24 UTC (rev 49188)
+++ trunk/mcs/gmcs/ChangeLog    2005-08-31 14:45:03 UTC (rev 49189)
@@ -1,5 +1,22 @@
 2005-07-15  Raja R Harinath  <[EMAIL PROTECTED]>
 
+       * codegen.cs (EmitContext.DeclSpace): Make readonly.
+       * namespace.cs (Namespace.Lookup): Carve out type lookup into ...
+       (Namespace.LookupType): ... this.
+       (NamespaceEntry.GetUsingTable): Allocate only one zero-sized array
+       of namespaces.1
+       * typemanager.cs (LookupTypeReflection): Remove buggy code that
+       purported to handle pointers.
+       (char_ptr_type, void_ptr_type): Use GetPointerType rather than
+       CoreLookupType.
+
+2005-07-15  Marek Safar  <[EMAIL PROTECTED]>
+
+       * expression.cs (MemberAccess.ResolveNamespaceOrType): Don't report 
nested
+       type as namespace.
+
+2005-07-15  Raja R Harinath  <[EMAIL PROTECTED]>
+
        * namespace.cs (Namespace.Lookup): Drop location parameter.
        (NamespaceEntry.LookupAlias): Remove.  Merge into ...
        (NamespaceEntry.Lookup): ... this.

Modified: trunk/mcs/gmcs/codegen.cs
===================================================================
--- trunk/mcs/gmcs/codegen.cs   2005-08-31 14:43:24 UTC (rev 49188)
+++ trunk/mcs/gmcs/codegen.cs   2005-08-31 14:45:03 UTC (rev 49189)
@@ -188,7 +188,7 @@
        ///   properties bodies, indexer bodies or constructor bodies)
        /// </summary>
        public class EmitContext {
-               public DeclSpace DeclSpace;
+               public readonly DeclSpace DeclSpace;
                public DeclSpace TypeContainer;
                public ILGenerator   ig;
 

Modified: trunk/mcs/gmcs/namespace.cs
===================================================================
--- trunk/mcs/gmcs/namespace.cs 2005-08-31 14:43:24 UTC (rev 49188)
+++ trunk/mcs/gmcs/namespace.cs 2005-08-31 14:45:03 UTC (rev 49189)
@@ -135,39 +135,42 @@
                        return Root.GetNamespace (name, create);
                }
 
+               TypeExpr LookupType (string name)
+               {
+                       if (cached_types.Contains (name))
+                               return cached_types [name] as TypeExpr;
+
+                       Type t;
+                       DeclSpace tdecl = declspaces [name] as DeclSpace;
+                       if (tdecl != null) {
+                               //
+                               // Note that this is not:
+                               //
+                               //   t = tdecl.DefineType ()
+                               //
+                               // This is to make it somewhat more useful when 
a DefineType
+                               // fails due to problems in nested types (more 
useful in the sense
+                               // of fewer misleading error messages)
+                               //
+                               tdecl.DefineType ();
+                               t = tdecl.TypeBuilder;
+                       } else {
+                               string lookup = this == Namespace.Root ? name : 
fullname + "." + name;
+                               t = TypeManager.LookupTypeReflection (lookup);
+                       }
+                       TypeExpr te = t == null ? null : new TypeExpression (t, 
Location.Null);
+                       cached_types [name] = te;
+                       return te;
+               }
+
                public FullNamedExpression Lookup (DeclSpace ds, string name)
                {
                        Namespace ns = GetNamespace (name, false);
                        if (ns != null)
                                return ns;
 
-                       TypeExpr te;
-                       if (cached_types.Contains (name)) {
-                               te = (TypeExpr) cached_types [name];
-                       } else {
-                               Type t;
-                               DeclSpace tdecl = declspaces [name] as 
DeclSpace;
-                               if (tdecl != null) {
-                                       //
-                                       // Note that this is not:
-                                       //
-                                       //   t = tdecl.DefineType ()
-                                       //
-                                       // This is to make it somewhat more 
useful when a DefineType
-                                       // fails due to problems in nested 
types (more useful in the sense
-                                       // of fewer misleading error messages)
-                                       //
-                                       tdecl.DefineType ();
-                                       t = tdecl.TypeBuilder;
-                               } else {
-                                       string lookup = this == Namespace.Root 
? name : fullname + "." + name;
-                                       t = TypeManager.LookupTypeReflection 
(lookup);
-                               }
-                               te = t == null ? null : new TypeExpression (t, 
Location.Null);
-                               cached_types [name] = te;
-                       }
-
-                       if (te != null && ds != null && !ds.CheckAccessLevel 
(te.Type))
+                       TypeExpr te = LookupType (name);
+                       if (te == null || !ds.CheckAccessLevel (te.Type))
                                return null;
 
                        return te;
@@ -431,7 +434,7 @@
                        if (aliases == null)
                                aliases = new Hashtable ();
 
-                       if (aliases.Contains (name)){
+                       if (aliases.Contains (name)) {
                                AliasEntry ae = (AliasEntry)aliases [name];
                                Report.SymbolRelatedToPreviousError 
(ae.Location, ae.Name);
                                Report.Error (1537, loc, "The using alias `" + 
name +
@@ -500,14 +503,15 @@
                }
 
                // Our cached computation.
+               readonly Namespace [] empty_namespaces = new Namespace [0];
                Namespace [] namespace_using_table;
-               Namespace[] GetUsingTable ()
+               Namespace [] GetUsingTable ()
                {
                        if (namespace_using_table != null)
                                return namespace_using_table;
 
                        if (using_clauses == null) {
-                               namespace_using_table = new Namespace [0];
+                               namespace_using_table = empty_namespaces;
                                return namespace_using_table;
                        }
 
@@ -558,7 +562,7 @@
                {
                        Console.WriteLine ("    Try using -r:" + s);
                }
-               
+
                static void MsgtryPkg (string s)
                {
                        Console.WriteLine ("    Try using -pkg:" + s);
@@ -599,19 +603,15 @@
                public void VerifyUsing ()
                {
                        if (using_clauses != null) {
-                               foreach (UsingEntry ue in using_clauses){
+                               foreach (UsingEntry ue in using_clauses)
                                        ue.Resolve ();
-                               }
                        }
 
-                       if (aliases != null){
+                       if (aliases != null) {
                                foreach (DictionaryEntry de in aliases) {
                                        AliasEntry alias = (AliasEntry) 
de.Value;
-
-                                       if (alias.Resolve () != null)
-                                               continue;
-
-                                       Error_NamespaceNotFound 
(alias.Location, alias.Alias.ToString ());
+                                       if (alias.Resolve () == null)
+                                               Error_NamespaceNotFound 
(alias.Location, alias.Alias.ToString ());
                                }
                        }
                }

Modified: trunk/mcs/gmcs/typemanager.cs
===================================================================
--- trunk/mcs/gmcs/typemanager.cs       2005-08-31 14:43:24 UTC (rev 49188)
+++ trunk/mcs/gmcs/typemanager.cs       2005-08-31 14:45:03 UTC (rev 49189)
@@ -721,39 +721,23 @@
                }
                return (Type) ret;
        }
-       
-       //
-       // Low-level lookup, cache-less
-       //
+
        public static Type LookupTypeReflection (string name)
        {
                Type t;
 
-               foreach (Assembly a in assemblies){
+               foreach (Assembly a in assemblies) {
                        t = a.GetType (name);
-                       if (t == null)
-                               continue;
-
-                       do {
+                       if (t != null) {
+                               if (t.IsPointer)
+                                       throw new InternalErrorException ("Use 
GetPointerType() to get a pointer");
                                TypeAttributes ta = t.Attributes & 
TypeAttributes.VisibilityMask;
-                               if (ta == TypeAttributes.NotPublic ||
-                                   ta == TypeAttributes.NestedPrivate ||
-                                   ta == TypeAttributes.NestedAssembly ||
-                                   ta == TypeAttributes.NestedFamANDAssem){
-                                       
-                                       //
-                                       // In .NET pointers turn out to be 
private, even if their
-                                       // element type is not
-                                       //
-                                       if (t.IsPointer){
-                                               t = t.GetElementType ();
-                                               continue;
-                                       } else
-                                               t = null;
-                               } else {
+                               if (ta != TypeAttributes.NotPublic &&
+                                   ta != TypeAttributes.NestedPrivate &&
+                                   ta != TypeAttributes.NestedAssembly &&
+                                   ta != TypeAttributes.NestedFamANDAssem)
                                        return t;
-                               }
-                       } while (t != null);
+                       }
                }
 
                foreach (Module mb in modules) {
@@ -761,7 +745,7 @@
                        if (t != null) 
                                return t;
                }
-                        
+
                return null;
        }
 
@@ -1162,7 +1146,7 @@
                string_type   = CoreLookupType ("System.String");
                float_type    = CoreLookupType ("System.Single");
                double_type   = CoreLookupType ("System.Double");
-               char_ptr_type = CoreLookupType ("System.Char*");
+               char_ptr_type = GetPointerType (char_type);
                decimal_type  = CoreLookupType ("System.Decimal");
                bool_type     = CoreLookupType ("System.Boolean");
                enum_type     = CoreLookupType ("System.Enum");
@@ -1204,7 +1188,7 @@
 
                unverifiable_code_type= CoreLookupType 
("System.Security.UnverifiableCodeAttribute");
 
-               void_ptr_type         = CoreLookupType ("System.Void*");
+               void_ptr_type         = GetPointerType (void_type);
 
                indexer_name_type     = CoreLookupType 
("System.Runtime.CompilerServices.IndexerNameAttribute");
 

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

Reply via email to