2002-12-08 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Mon, 9 Dec 2002 03:10:33 +0000 (03:10 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 9 Dec 2002 03:10:33 +0000 (03:10 -0000)
* ecore.cs (SimpleName.DoResolve): First perform lookups on using
definitions, instead of doing that afterwards.

Also we use a nice little hack, depending on the constructor, we
know if we are a "composed" name or a simple name.  Hence, we
avoid the IndexOf test, and we avoid

* codegen.cs: Add code to assist in a bug reporter to track down
the source of a compiler crash.

svn path=/trunk/mcs/; revision=9465

mcs/mcs/ChangeLog
mcs/mcs/codegen.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs

index 58e9657c052ee5c809ac99f99c21ac68b4ea2873..2f308b889de6865415b799502f9e79b5d82ba956 100755 (executable)
@@ -1,3 +1,15 @@
+2002-12-08  Miguel de Icaza  <miguel@ximian.com>
+
+       * ecore.cs (SimpleName.DoResolve): First perform lookups on using
+       definitions, instead of doing that afterwards.  
+
+       Also we use a nice little hack, depending on the constructor, we
+       know if we are a "composed" name or a simple name.  Hence, we
+       avoid the IndexOf test, and we avoid 
+
+       * codegen.cs: Add code to assist in a bug reporter to track down
+       the source of a compiler crash. 
+
 2002-12-07  Ravi Pratap  <ravi@ximian.com>
 
        * attribute.cs (Attribute.ApplyAttributes) : Keep track of which attribute
index f22dd3465bff1c21ac4ba86e7ccf6336e0a54ba7..94e9ab805218373a8945c1efbe6cd9f418a6e975 100755 (executable)
@@ -497,6 +497,7 @@ namespace Mono.CSharp {
                                Mark (loc);
 
                        if (block != null){
+                               try {
                                int errors = Report.Errors;
 
                                block.EmitMeta (this, block);
@@ -531,6 +532,13 @@ namespace Mono.CSharp {
                                                        block.UsageWarning ();
                                        }
                                }
+                               } catch {
+                                       Console.WriteLine ("Exception caught by the compiler while compiling:");
+                                       Console.WriteLine ("   Block that caused the problem begin at: " + loc);
+                                       Console.WriteLine ("                     Block being compiled: [{0},{1}]",
+                                                          CurrentBlock.StartLocation, CurrentBlock.EndLocation);
+                                       throw;
+                               }
                        }
 
                        if (ReturnType != null && !has_ret){
index 7de3fd61f662e0ae88a0c62cbdfa32355db0a5f3..0348aec37aa5c97d1a49cc56dc48877683b8aa24 100755 (executable)
@@ -3431,11 +3431,24 @@ namespace Mono.CSharp {
        /// </remarks>
        public class SimpleName : Expression, ITypeExpression {
                public readonly string Name;
+
+               //
+               // If true, then we are a simple name, not composed with a ".
+               //
+               bool is_base;
+
+               public SimpleName (string a, string b, Location l)
+               {
+                       Name = String.Concat (a, ".", b);
+                       loc = l;
+                       is_base = false;
+               }
                
                public SimpleName (string name, Location l)
                {
                        Name = name;
                        loc = l;
+                       is_base = true;
                }
 
                public static void Error_ObjectRefRequired (EmitContext ec, Location l, string name)
@@ -3488,14 +3501,26 @@ namespace Mono.CSharp {
 
                public Expression DoResolveType (EmitContext ec)
                {
-                       //
-                       // Stage 3: Lookup symbol in the various namespaces. 
-                       //
                        DeclSpace ds = ec.DeclSpace;
+                       Namespace ns = ds.Namespace;
                        Type t;
                        string alias_value;
 
+                       //
+                       // Since we are cheating: we only do the Alias lookup for
+                       // namespaces if the name does not include any dots in it
+                       //
+                       if (ns != null && is_base)
+                               alias_value = ns.LookupAlias (Name);
+                       else
+                               alias_value = null;
+                               
                        if (ec.ResolvingTypeTree){
+                               if (alias_value != null){
+                                       if ((t = RootContext.LookupType (ds, alias_value, true, loc)) != null)
+                                               return new TypeExpr (t, loc);
+                               }
+                               
                                int errors = Report.Errors;
                                Type dt = ec.DeclSpace.FindType (loc, Name);
                                if (Report.Errors != errors)
@@ -3505,27 +3530,24 @@ namespace Mono.CSharp {
                                        return new TypeExpr (dt, loc);
                        }
 
-                       if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
-                               return new TypeExpr (t, loc);
-                               
-
                        //
-                       // Stage 2 part b: Lookup up if we are an alias to a type
-                       // or a namespace.
+                       // First, the using aliases
                        //
-                       // Since we are cheating: we only do the Alias lookup for
-                       // namespaces if the name does not include any dots in it
-                       //
-                               
-                       alias_value = ec.DeclSpace.LookupAlias (Name);
-                               
-                       if (Name.IndexOf ('.') == -1 && alias_value != null) {
+                       if (alias_value != null){
                                if ((t = RootContext.LookupType (ds, alias_value, true, loc)) != null)
                                        return new TypeExpr (t, loc);
-                                       
+                               
                                // we have alias value, but it isn't Type, so try if it's namespace
                                return new SimpleName (alias_value, loc);
                        }
+                       
+                       //
+                       // Stage 2: Lookup up if we are an alias to a type
+                       // or a namespace.
+                       //
+                               
+                       if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
+                               return new TypeExpr (t, loc);
                                
                        // No match, maybe our parent can compose us
                        // into something meaningful.
index 9d71f7c0243f52a97b65f35504abf22c5b5ae0a0..3b7703628702641b9a040ee1d37a872f341e5836 100755 (executable)
@@ -6066,7 +6066,7 @@ namespace Mono.CSharp {
                        if (expr is SimpleName){
                                SimpleName child_expr = (SimpleName) expr;
                                
-                               Expression new_expr = new SimpleName (child_expr.Name + "." + Identifier, loc);
+                               Expression new_expr = new SimpleName (child_expr.Name, Identifier, loc);
 
                                return new_expr.Resolve (ec, flags);
                        }