2004-05-30 Ben Maurer <bmaurer@users.sourceforge.net>
authorBen Maurer <benm@mono-cvs.ximian.com>
Sun, 30 May 2004 20:37:58 +0000 (20:37 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Sun, 30 May 2004 20:37:58 +0000 (20:37 -0000)
* expression.cs:
According to the spec,

In a member access of the form E.I, if E is a single identifier,
and if the meaning of E as a simple-name (�7.5.2) is a constant,
field, property, localvariable, or parameter with the same type as
the meaning of E as a type-name (�3.8), then both possible
meanings of E are permitted.

We did not check that E as a simple-name had the same type as E as
a type name.

This trivial check gives us 5-7% on bootstrap time.

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

mcs/mcs/ChangeLog
mcs/mcs/expression.cs

index e0e434ad0e2371a268205ebeeda5863b6a795fa4..b9e1bd71c3bddc0158a808e455cf1b6adfb5c8e6 100755 (executable)
@@ -1,3 +1,19 @@
+2004-05-30 Ben Maurer  <bmaurer@users.sourceforge.net>
+
+       * expression.cs:
+       According to the spec, 
+
+       In a member access of the form E.I, if E is a single identifier,
+       and if the meaning of E as a simple-name (§7.5.2) is a constant,
+       field, property, localvariable, or parameter with the same type as
+       the meaning of E as a type-name (§3.8), then both possible
+       meanings of E are permitted.
+
+       We did not check that E as a simple-name had the same type as E as
+       a type name.
+
+       This trivial check gives us 5-7% on bootstrap time.
+
 2004-05-30  Marek Safar  <marek.safar@seznam.cz>
 
        Fixed bug #59071 & cs0160.cs
index 87abae0e0aaf53f08c2aad8b708dbe4035090b30..b4d36d88a925475a8e7bfb9cff6a081b9f94c02a 100755 (executable)
@@ -6763,21 +6763,13 @@ namespace Mono.CSharp {
                                      "type name instead");
                }
 
-               static bool IdenticalNameAndTypeName (EmitContext ec, Expression left_original, Location loc)
+               static bool IdenticalNameAndTypeName (EmitContext ec, Expression left_original, Expression left, Location loc)
                {
-                       if (left_original == null)
+                       SimpleName sn = left_original as SimpleName;
+                       if (sn == null || left == null || left.Type.Name != sn.Name)
                                return false;
 
-                       if (!(left_original is SimpleName))
-                               return false;
-
-                       SimpleName sn = (SimpleName) left_original;
-
-                       Type t = RootContext.LookupType (ec.DeclSpace, sn.Name, true, loc);
-                       if (t != null)
-                               return true;
-
-                       return false;
+                       return RootContext.LookupType (ec.DeclSpace, sn.Name, true, loc) != null;
                }
                
                public static Expression ResolveMemberAccess (EmitContext ec, Expression member_lookup,
@@ -6831,7 +6823,7 @@ namespace Mono.CSharp {
                                        
                                        if (decl_type.IsSubclassOf (TypeManager.enum_type)) {
                                                if (left_is_explicit && !left_is_type &&
-                                                   !IdenticalNameAndTypeName (ec, left_original, loc)) {
+                                                   !IdenticalNameAndTypeName (ec, left_original, member_lookup, loc)) {
                                                        error176 (loc, fe.FieldInfo.Name);
                                                        return null;
                                                }                                       
@@ -6915,23 +6907,23 @@ namespace Mono.CSharp {
 
                                        if (!me.IsStatic){
                                                if ((ec.IsFieldInitializer || ec.IsStatic) &&
-                                                   IdenticalNameAndTypeName (ec, left_original, loc))
+                                                   IdenticalNameAndTypeName (ec, left_original, member_lookup, loc))
                                                        return member_lookup;
-
+                                               
                                                SimpleName.Error_ObjectRefRequired (ec, loc, me.Name);
                                                return null;
                                        }
 
                                } else {
-                                       if (!me.IsInstance){
-                                               if (IdenticalNameAndTypeName (ec, left_original, loc))
+                                       if (!me.IsInstance) {
+                                               if (IdenticalNameAndTypeName (ec, left_original, left, loc))
                                                        return member_lookup;
 
                                                if (left_is_explicit) {
                                                        error176 (loc, me.Name);
                                                        return null;
                                                }
-                                       }                                               
+                                       }                       
 
                                        //
                                        // Since we can not check for instance objects in SimpleName,
@@ -6954,7 +6946,7 @@ namespace Mono.CSharp {
                                                }
                                        }
 
-                                       if ((mg != null) && IdenticalNameAndTypeName (ec, left_original, loc))
+                                       if ((mg != null) && IdenticalNameAndTypeName (ec, left_original, left, loc))
                                                mg.IdenticalTypeName = true;
 
                                        me.InstanceExpression = left;