Author: martin
Date: 2005-03-21 07:38:38 -0500 (Mon, 21 Mar 2005)
New Revision: 42047

Modified:
   trunk/mcs/gmcs/AssemblyInfo.cs
   trunk/mcs/gmcs/ChangeLog
   trunk/mcs/gmcs/attribute.cs
   trunk/mcs/gmcs/cs-parser.jay
   trunk/mcs/gmcs/ecore.cs
   trunk/mcs/gmcs/expression.cs
   trunk/mcs/gmcs/location.cs
Log:
**** Merged r39643-r39898 from MCS ****


Modified: trunk/mcs/gmcs/AssemblyInfo.cs
===================================================================
--- trunk/mcs/gmcs/AssemblyInfo.cs      2005-03-21 12:35:00 UTC (rev 42046)
+++ trunk/mcs/gmcs/AssemblyInfo.cs      2005-03-21 12:38:38 UTC (rev 42047)
@@ -1,7 +1,7 @@
 using System.Reflection;
 using System.Runtime.CompilerServices;
 
-[assembly: AssemblyVersion("1.1.3")]
+[assembly: AssemblyVersion("1.1.4")]
 [assembly: AssemblyTitle ("Mono C# Compiler")]
 [assembly: AssemblyDescription ("Mono C# Compiler with Generics")]
 [assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]

Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog    2005-03-21 12:35:00 UTC (rev 42046)
+++ trunk/mcs/gmcs/ChangeLog    2005-03-21 12:38:38 UTC (rev 42047)
@@ -1,3 +1,36 @@
+2005-01-29  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * pending.cs: Produce better code (no nops produced by using Ldarg
+       + value).
+       
+       * pending.cs (PendingImplementation.DefineProxy): It was not `arg
+       i - 1' it should be arg + 1.
+
+       Fixes bug #71819.
+
+2005-01-28  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * attribute.cs (Attribute.CheckAttributeType): Make private
+       non-virtual.
+       (Attribute.ResolveType): Make virtual.
+       (GlobalAttribute.ResolveType,GlobalAttribute.Resolve): Simplify
+       handling of RootContext.Tree.Types.
+
+2005-01-27  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       Update attribute-handling to use the SimpleName/MemberAccess
+       mechanisms.
+       * cs-parser.jay (attribute): Pass in an expression to the
+       constructors of Attribute and GlobalAttribute.
+       * attribute.cs (Attribute): Take an expression for the name.
+       (Attribute.ResolvePossibleAttributeTypes): New.  Resolves the
+       passed in attribute name expression.
+       (Attribute.CheckAttributeType): Use it.
+       * ecore.cs (FullNamedExpression.ResolveAsTypeStep): New.
+       * expression.cs (MemberAccess.ResolveAsTypeStep): Move body to ...
+       (MemberAccess.ResolveNamespaceOrType): ... here.  Add 'silent'
+       argument to prevent error messages if the lookup fails.
+
 2005-01-27  Marek Safar  <[EMAIL PROTECTED]>
 
        * expression.cs (Indirection): Implemented IVariable interface

Modified: trunk/mcs/gmcs/attribute.cs
===================================================================
--- trunk/mcs/gmcs/attribute.cs 2005-03-21 12:35:00 UTC (rev 42046)
+++ trunk/mcs/gmcs/attribute.cs 2005-03-21 12:38:38 UTC (rev 42047)
@@ -72,6 +72,9 @@
                public AttributeTargets Target;
 
                public readonly string    Name;
+               public readonly Expression LeftExpr;
+               public readonly string Identifier;
+
                public readonly ArrayList Arguments;
 
                public readonly Location Location;
@@ -102,9 +105,11 @@
 
                static PtrHashtable usage_attr_cache = new PtrHashtable ();
                
-               public Attribute (string target, string name, ArrayList args, 
Location loc)
+               public Attribute (string target, Expression left_expr, string 
identifier, ArrayList args, Location loc)
                {
-                       Name = name;
+                       LeftExpr = left_expr;
+                       Identifier = identifier;
+                       Name = LeftExpr == null ? identifier : LeftExpr + "." + 
identifier;
                        Arguments = args;
                        Location = loc;
                        ExplicitTarget = target;
@@ -114,7 +119,7 @@
                {
                        Report.Error (617, Location, "Invalid attribute 
argument: '{0}'.  Argument must be fields " +
                                      "fields which are not readonly, static or 
const;  or read-write instance properties.",
-                                     Name);
+                                     name);
                }
 
                static void Error_AttributeArgumentNotValid (string extra, 
Location loc)
@@ -155,27 +160,50 @@
                                       "Could not find a constructor for this 
argument list.");
                }
 
+               void ResolvePossibleAttributeTypes (EmitContext ec, out Type 
t1, out Type t2)
+               {
+                       t1 = null;
+                       t2 = null;
+
+                       FullNamedExpression n1 = null;
+                       FullNamedExpression n2 = null;
+                       string IdentifierAttribute = Identifier + "Attribute";
+                       if (LeftExpr == null) {
+                               n1 = new SimpleName (Identifier, 
Location).ResolveAsTypeStep (ec);
+
+                               // FIXME: Shouldn't do this for quoted 
attributes: [EMAIL PROTECTED]
+                               n2 = new SimpleName (IdentifierAttribute, 
Location).ResolveAsTypeStep (ec);
+                       } else {
+                               FullNamedExpression l = 
LeftExpr.ResolveAsTypeStep (ec);
+                               if (l == null) {
+                                       Report.Error (246, Location, "Couldn't 
find namespace or type '{0}'", LeftExpr);
+                                       return;
+                               }
+                               n1 = new MemberAccess (l, Identifier, 
Location).ResolveNamespaceOrType (ec, true);
+
+                               // FIXME: Shouldn't do this for quoted 
attributes: [EMAIL PROTECTED]
+                               n2 = new MemberAccess (l, IdentifierAttribute, 
Location).ResolveNamespaceOrType (ec, true);
+                       }
+
+                       TypeExpr te1 = n1 == null ? null : n1 as TypeExpr;
+                       TypeExpr te2 = n2 == null ? null : n2 as TypeExpr;      
                
+
+                       if (te1 != null)
+                               t1 = te1.ResolveType (ec);
+                       if (te2 != null)
+                               t2 = te2.ResolveType (ec);
+               }
+
                /// <summary>
                 ///   Tries to resolve the type of the attribute. Flags an 
error if it can't, and complain is true.
                 /// </summary>
-               protected virtual Type CheckAttributeType (EmitContext ec)
+               Type CheckAttributeType (EmitContext ec)
                {
+                       Type t1, t2;
+                       ResolvePossibleAttributeTypes (ec, out t1, out t2);
+
                        string NameAttribute = Name + "Attribute";
-                       FullNamedExpression n1 = ec.ResolvingTypeTree
-                               ? ec.DeclSpace.FindType (Location, Name)
-                               : ec.DeclSpace.LookupType (Name, true, 
Location);
 
-                       // FIXME: Shouldn't do this for quoted attributes: 
[EMAIL PROTECTED]
-                       FullNamedExpression n2 = ec.ResolvingTypeTree
-                               ? ec.DeclSpace.FindType (Location, 
NameAttribute)
-                               : ec.DeclSpace.LookupType (NameAttribute, true, 
Location);
-
-                       TypeExpr e1 = n1 == null ? null : n1 as TypeExpr;
-                       TypeExpr e2 = n2 == null ? null : n2 as TypeExpr;       
                
-
-                       Type t1 = e1 == null ? null : e1.ResolveType (ec);
-                       Type t2 = e2 == null ? null : e2.ResolveType (ec);
-
                        String err0616 = null;
                        if (t1 != null && ! t1.IsSubclassOf 
(TypeManager.attribute_type)) {
                                t1 = null;
@@ -210,7 +238,7 @@
                        return null;
                }
 
-               public Type ResolveType (EmitContext ec)
+               public virtual Type ResolveType (EmitContext ec)
                {
                        if (Type == null)
                                Type = CheckAttributeType (ec);
@@ -1191,52 +1219,46 @@
        {
                public readonly NamespaceEntry ns;
 
-               public GlobalAttribute (TypeContainer container, string target, 
string name, ArrayList args, Location loc):
-                       base (target, name, args, loc)
+               public GlobalAttribute (TypeContainer container, string target, 
+                                       Expression left_expr, string 
identifier, ArrayList args, Location loc):
+                       base (target, left_expr, identifier, args, loc)
                {
                        ns = container.NamespaceEntry;
                }
 
-               protected override Type CheckAttributeType (EmitContext ec)
+               void Enter ()
                {
                        // RootContext.Tree.Types has a single NamespaceEntry 
which gets overwritten
                        // each time a new file is parsed.  However, we need to 
use the NamespaceEntry
                        // in effect where the attribute was used.  Since code 
elsewhere cannot assume
                        // that the NamespaceEntry is right, just overwrite it.
                        //
-                       // Precondition: RootContext.Tree.Types == null || 
RootContext.Tree.Types == ns.
-                       //               The second case happens when we are 
recursively invoked from inside Emit.
+                       // Precondition: RootContext.Tree.Types == null
 
-                       NamespaceEntry old = null;
-                       if (ec.DeclSpace == RootContext.Tree.Types) {
-                               old = ec.DeclSpace.NamespaceEntry;
-                               ec.DeclSpace.NamespaceEntry = ns;
-                               if (old != null && old != ns)
-                                       throw new InternalErrorException 
(Location + " non-null NamespaceEntry " + old);
-                       }
+                       if (RootContext.Tree.Types.NamespaceEntry != null)
+                               throw new InternalErrorException (Location + " 
non-null NamespaceEntry");
 
-                       Type retval = base.CheckAttributeType (ec);
+                       RootContext.Tree.Types.NamespaceEntry = ns;
+               }
 
-                       if (ec.DeclSpace == RootContext.Tree.Types)
-                               ec.DeclSpace.NamespaceEntry = old;
+               void Leave ()
+               {
+                       RootContext.Tree.Types.NamespaceEntry = null;
+               }
 
+               public override Type ResolveType (EmitContext ec)
+               {
+                       Enter ();
+                       Type retval = base.ResolveType (ec);
+                       Leave ();
                        return retval;
                }
 
                public override CustomAttributeBuilder Resolve (EmitContext ec)
                {
-                       if (ec.DeclSpace == RootContext.Tree.Types) {
-                               NamespaceEntry old = 
ec.DeclSpace.NamespaceEntry;
-                               ec.DeclSpace.NamespaceEntry = ns;
-                               if (old != null)
-                                       throw new InternalErrorException 
(Location + " non-null NamespaceEntry " + old);
-                       }
-
+                       Enter ();
                        CustomAttributeBuilder retval = base.Resolve (ec);
-
-                       if (ec.DeclSpace == RootContext.Tree.Types)
-                               ec.DeclSpace.NamespaceEntry = null;
-
+                       Leave ();
                        return retval;
                }
        }

Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay        2005-03-21 12:35:00 UTC (rev 42046)
+++ trunk/mcs/gmcs/cs-parser.jay        2005-03-21 12:38:38 UTC (rev 42047)
@@ -622,19 +622,23 @@
          }
          opt_attribute_arguments
          {
+               Location loc = (Location) $2;
                MemberName mname = (MemberName) $1;
                if (mname.IsGeneric) {
                        Report.Error (404, lexer.Location,
                                      "'<' unexpected: attributes cannot be 
generic");
                }
 
-               string name = mname.GetName ();
+               MemberName left = mname.Left;
+               string identifier = mname.Name;
+
+               Expression left_expr = left == null ? null : 
left.GetTypeExpression (loc);
+
                if (current_attr_target == "assembly" || current_attr_target == 
"module")
                        $$ = new GlobalAttribute (current_container, 
current_attr_target,
-                                                 name, (ArrayList) $3, 
(Location) $2);
+                                                 left_expr, identifier, 
(ArrayList) $3, loc);
                else
-                       $$ = new Attribute (current_attr_target, name, 
(ArrayList) $3,
-                                           (Location) $2);
+                       $$ = new Attribute (current_attr_target, left_expr, 
identifier, (ArrayList) $3, loc);
          }
        ;
 

Modified: trunk/mcs/gmcs/ecore.cs
===================================================================
--- trunk/mcs/gmcs/ecore.cs     2005-03-21 12:35:00 UTC (rev 42046)
+++ trunk/mcs/gmcs/ecore.cs     2005-03-21 12:38:38 UTC (rev 42047)
@@ -2278,6 +2278,11 @@
        ///   section 10.8.1 (Fully Qualified Names).
        /// </summary>
        public abstract class FullNamedExpression : Expression {
+               public override FullNamedExpression ResolveAsTypeStep 
(EmitContext ec)
+               {
+                       return this;
+               }
+
                public abstract string FullName {
                        get;
                }

Modified: trunk/mcs/gmcs/expression.cs
===================================================================
--- trunk/mcs/gmcs/expression.cs        2005-03-21 12:35:00 UTC (rev 42046)
+++ trunk/mcs/gmcs/expression.cs        2005-03-21 12:38:38 UTC (rev 42047)
@@ -7641,6 +7641,11 @@
 
                public override FullNamedExpression ResolveAsTypeStep 
(EmitContext ec)
                {
+                       return ResolveNamespaceOrType (ec, false);
+               }
+
+               public FullNamedExpression ResolveNamespaceOrType (EmitContext 
ec, bool silent)
+               {
                        FullNamedExpression new_expr = expr.ResolveAsTypeStep 
(ec);
 
                        if (new_expr == null)
@@ -7653,7 +7658,7 @@
                                FullNamedExpression retval = ns.Lookup 
(ec.DeclSpace, lookup_id, loc);
                                if ((retval != null) && (args != null))
                                        retval = new ConstructedType (retval, 
args, loc).ResolveAsTypeStep (ec);
-                               if (retval == null)
+                               if (!silent && retval == null)
                                        Report.Error (234, loc, "The type or 
namespace name `{0}' could not be found in namespace `{1}'", Identifier, 
ns.FullName);
                                return retval;
                        }
@@ -7672,7 +7677,7 @@
 
                        Expression member_lookup;
                        member_lookup = MemberLookupFinal (ec, expr_type, 
expr_type, lookup_id, loc);
-                       if (member_lookup == null) {
+                       if (!silent && member_lookup == null) {
                                Report.Error (234, loc, "The type name `{0}' 
could not be found in type `{1}'", 
                                              Identifier, new_expr.FullName);
                                return null;

Modified: trunk/mcs/gmcs/location.cs
===================================================================
--- trunk/mcs/gmcs/location.cs  2005-03-21 12:35:00 UTC (rev 42046)
+++ trunk/mcs/gmcs/location.cs  2005-03-21 12:38:38 UTC (rev 42047)
@@ -57,7 +57,7 @@
        ///   in 8 bits (and say, map anything after char 255 to be `255+').
        /// </remarks>
        public struct Location {
-               public int token; 
+               int token; 
 
                static ArrayList source_list;
                static Hashtable source_files;

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

Reply via email to