2004-09-10 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Mon, 13 Sep 2004 14:38:16 +0000 (14:38 -0000)
committerMartin Baulig <martin@novell.com>
Mon, 13 Sep 2004 14:38:16 +0000 (14:38 -0000)
Backported my MemberName changes from GMCS into MCS.

- we are now using a special `MemberName' class instead of using
strings; in GMCS, the `MemberName' also contains the type
arguments.

- changed the grammar rules a bit:
  * the old `member_name' is now a `namespace_or_type_name':
    The rule is that we use `namespace_or_type_name' everywhere
    where we expect either a "member name" (GetEnumerator) or a
    "member name" with an explicit interface name
    (IEnumerable.GetEnumerator).
    In GMCS, the explicit interface name may include type arguments
    (IEnumerable<T>.GetEnumerator).
  * we use `member_name' instead of just `IDENTIFIER' for
    "member names":
    The rule is that we use `member_name' wherever a member may
    have type parameters in GMCS.

* decl.cs (MemberName): New public class.
(MemberCore.MemberName): New public readonly field.
(MemberCore.ctor): Take a `MemberName' argument, not a string.
(DeclSpace): Likewise.

* delegate.cs (Delegate.ctor): Take a MemberName, not a string.
* enum.cs (Enum.ctor): Likewise.

* namespace.cs (AliasEntry.Alias): Changed type from Expression to
MemberName.
(AliasEntry.ctor): Take a MemberName, not an Expression.
(AliasEntry.UsingAlias): Likewise.

* class.cs (TypeContainer.ctor): Take a MemberName, not a string.
(IMethodData.MemberName): Changed type from string to MemberName.
(MemberBase.ExplicitInterfaceName): Likewise.
(AbstractPropertyEventMethod.SetupName): Make this private.
(AbstractPropertyEventMethod.ctor): Added `string prefix'
argument; compute the member name here.
(AbstractPropertyEventMethod.UpdateName): Recompute the name based
on the `member.MemberName' and the `prefix'.

* cs-parser.jay (attribute_name): Use `namespace_or_type_name',
not `type_name'.
(struct_declaration): Use `member_name' instead of `IDENTIFIER';
thus, we get a `MemberName' instead of a `string'.  These
declarations may have type parameters in GMCS.
(interface_method_declaration, delegate_declaration): Likewise.
(class_declaration, interface_declaration): Likewise.
(method_header): Use `namespace_or_type_name' instead of
`member_name'.  We may be an explicit interface implementation.
(property_declaration, event_declaration): Likewise.
(member_name): This is now just an `IDENTIFIER', not a
`namespace_or_type_name'.
(type_name, interface_type): Removed.
(namespace_or_type_name): Return a MemberName, not an Expression.
(primary_expression): Use `member_name' instead of `IDENTIFIER';
call GetTypeExpression() on the MemberName to get an expression.
(IndexerDeclaration.interface_type): Changed type from string to
MemberName.
(MakeName): Operate on MemberName's instead of string's.

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

mcs/mcs/ChangeLog
mcs/mcs/class.cs
mcs/mcs/const.cs
mcs/mcs/cs-parser.jay
mcs/mcs/decl.cs
mcs/mcs/delegate.cs
mcs/mcs/enum.cs
mcs/mcs/iterators.cs
mcs/mcs/namespace.cs
mcs/mcs/tree.cs

index 07ba796d129f1695f64250c3bf49547c3311e045..814345f4f4d0cae65523770457f667cf7aa00590 100755 (executable)
@@ -1,3 +1,66 @@
+2004-09-10  Martin Baulig  <martin@ximian.com>
+
+       Backported my MemberName changes from GMCS into MCS.
+
+       - we are now using a special `MemberName' class instead of using
+       strings; in GMCS, the `MemberName' also contains the type
+       arguments.
+
+       - changed the grammar rules a bit:
+         * the old `member_name' is now a `namespace_or_type_name':
+           The rule is that we use `namespace_or_type_name' everywhere
+           where we expect either a "member name" (GetEnumerator) or a
+           "member name" with an explicit interface name
+           (IEnumerable.GetEnumerator).
+           In GMCS, the explicit interface name may include type arguments
+           (IEnumerable<T>.GetEnumerator).
+         * we use `member_name' instead of just `IDENTIFIER' for
+           "member names":
+           The rule is that we use `member_name' wherever a member may
+           have type parameters in GMCS.       
+
+       * decl.cs (MemberName): New public class.
+       (MemberCore.MemberName): New public readonly field.
+       (MemberCore.ctor): Take a `MemberName' argument, not a string.
+       (DeclSpace): Likewise.
+
+       * delegate.cs (Delegate.ctor): Take a MemberName, not a string.
+       * enum.cs (Enum.ctor): Likewise.
+
+       * namespace.cs (AliasEntry.Alias): Changed type from Expression to
+       MemberName.     
+       (AliasEntry.ctor): Take a MemberName, not an Expression.
+       (AliasEntry.UsingAlias): Likewise.
+
+       * class.cs (TypeContainer.ctor): Take a MemberName, not a string.
+       (IMethodData.MemberName): Changed type from string to MemberName.
+       (MemberBase.ExplicitInterfaceName): Likewise.
+       (AbstractPropertyEventMethod.SetupName): Make this private.
+       (AbstractPropertyEventMethod.ctor): Added `string prefix'
+       argument; compute the member name here.
+       (AbstractPropertyEventMethod.UpdateName): Recompute the name based
+       on the `member.MemberName' and the `prefix'.
+
+       * cs-parser.jay (attribute_name): Use `namespace_or_type_name',
+       not `type_name'.
+       (struct_declaration): Use `member_name' instead of `IDENTIFIER';
+       thus, we get a `MemberName' instead of a `string'.  These
+       declarations may have type parameters in GMCS.
+       (interface_method_declaration, delegate_declaration): Likewise.
+       (class_declaration, interface_declaration): Likewise.
+       (method_header): Use `namespace_or_type_name' instead of
+       `member_name'.  We may be an explicit interface implementation.
+       (property_declaration, event_declaration): Likewise.
+       (member_name): This is now just an `IDENTIFIER', not a
+       `namespace_or_type_name'.
+       (type_name, interface_type): Removed.
+       (namespace_or_type_name): Return a MemberName, not an Expression.
+       (primary_expression): Use `member_name' instead of `IDENTIFIER';
+       call GetTypeExpression() on the MemberName to get an expression.
+       (IndexerDeclaration.interface_type): Changed type from string to
+       MemberName.
+       (MakeName): Operate on MemberName's instead of string's.
+
 2004-09-13  Raja R Harinath  <rharinath@novell.com>
 
        Fix bug #55770.
index b845cf022b74815b951c9bf32432b9d50ceb51f8..06d56bb8959a501db250b4e3a6b06650cf07eca2 100755 (executable)
@@ -454,7 +454,7 @@ namespace Mono.CSharp {
 
                public const string DefaultIndexerName = "Item";
                
-               public TypeContainer (NamespaceEntry ns, TypeContainer parent, string name,
+               public TypeContainer (NamespaceEntry ns, TypeContainer parent, MemberName name,
                                      Attributes attrs, Kind kind, Location l)
                        : base (ns, parent, name, attrs, l)
                {
@@ -2399,11 +2399,12 @@ namespace Mono.CSharp {
                public readonly TypeAttributes DefaultTypeAttributes;
 
                static PartialContainer Create (NamespaceEntry ns, TypeContainer parent,
-                                               string name, int mod_flags, Kind kind,
+                                               MemberName name, int mod_flags, Kind kind,
                                                Location loc)
                {
                        PartialContainer pc;
-                       DeclSpace ds = (DeclSpace) RootContext.Tree.Decls [name];
+                       string full_name = name.GetName (true);
+                       DeclSpace ds = (DeclSpace) RootContext.Tree.Decls [full_name];
                        if (ds != null) {
                                pc = ds as PartialContainer;
 
@@ -2438,14 +2439,14 @@ namespace Mono.CSharp {
                        }
 
                        pc = new PartialContainer (ns, parent, name, mod_flags, kind, loc);
-                       RootContext.Tree.RecordDecl (name, pc);
+                       RootContext.Tree.RecordDecl (full_name, pc);
                        parent.AddType (pc);
                        pc.Register ();
                        return pc;
                }
 
                public static ClassPart CreatePart (NamespaceEntry ns, TypeContainer parent,
-                                                   string name, int mod, Attributes attrs,
+                                                   MemberName name, int mod, Attributes attrs,
                                                    Kind kind, Location loc)
                {
                        PartialContainer pc = Create (ns, parent, name, mod, kind, loc);
@@ -2461,7 +2462,7 @@ namespace Mono.CSharp {
                }
 
                protected PartialContainer (NamespaceEntry ns, TypeContainer parent,
-                                           string name, int mod, Kind kind, Location l)
+                                           MemberName name, int mod, Kind kind, Location l)
                        : base (ns, parent, name, null, kind, l)
                {
                        this.Namespace = ns.NS;
@@ -2532,7 +2533,7 @@ namespace Mono.CSharp {
 
                public ClassPart (NamespaceEntry ns, PartialContainer parent,
                                  int mod, Attributes attrs, Kind kind, Location l)
-                       : base (ns, parent.Parent, parent.Name, attrs, kind, l)
+                       : base (ns, parent.Parent, parent.MemberName, attrs, kind, l)
                {
                        this.PartialContainer = parent;
                        this.IsPartial = true;
@@ -2574,7 +2575,7 @@ namespace Mono.CSharp {
                bool hasExplicitLayout = false;
 
                public ClassOrStruct (NamespaceEntry ns, TypeContainer parent,
-                                     string name, Attributes attrs, Kind kind,
+                                     MemberName name, Attributes attrs, Kind kind,
                                      Location l)
                        : base (ns, parent, name, attrs, kind, l)
                {
@@ -2632,7 +2633,7 @@ namespace Mono.CSharp {
        /// Class handles static classes declaration
        /// </summary>
        public sealed class StaticClass: Class {
-               public StaticClass (NamespaceEntry ns, TypeContainer parent, string name, int mod,
+               public StaticClass (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
                        Attributes attrs, Location l)
                        : base (ns, parent, name, mod & ~Modifiers.STATIC, attrs, l)
                {
@@ -2714,7 +2715,7 @@ namespace Mono.CSharp {
                // Information in the case we are an attribute type
                AttributeUsageAttribute attribute_usage;
 
-               public Class (NamespaceEntry ns, TypeContainer parent, string name, int mod,
+               public Class (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
                              Attributes attrs, Location l)
                        : base (ns, parent, name, attrs, Kind.Class, l)
                {
@@ -2784,7 +2785,7 @@ namespace Mono.CSharp {
                        Modifiers.UNSAFE    |
                        Modifiers.PRIVATE;
 
-               public Struct (NamespaceEntry ns, TypeContainer parent, string name,
+               public Struct (NamespaceEntry ns, TypeContainer parent, MemberName name,
                               int mod, Attributes attrs, Location l)
                        : base (ns, parent, name, attrs, Kind.Struct, l)
                {
@@ -2838,7 +2839,7 @@ namespace Mono.CSharp {
                        Modifiers.UNSAFE    |
                        Modifiers.PRIVATE;
 
-               public Interface (NamespaceEntry ns, TypeContainer parent, string name, int mod,
+               public Interface (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
                                  Attributes attrs, Location l)
                        : base (ns, parent, name, attrs, Kind.Interface, l)
                {
@@ -2901,7 +2902,7 @@ namespace Mono.CSharp {
                static string[] attribute_targets = new string [] { "method", "return" };
 
                public MethodCore (TypeContainer parent, Expression type, int mod,
-                                  int allowed_mod, bool is_interface, string name,
+                                  int allowed_mod, bool is_interface, MemberName name,
                                   Attributes attrs, Parameters parameters, Location loc)
                        : base (parent, type, mod, allowed_mod, Modifiers.PRIVATE, name,
                                attrs, loc)
@@ -3354,7 +3355,8 @@ namespace Mono.CSharp {
                // return_type can be "null" for VOID values.
                //
                public Method (TypeContainer ds, Expression return_type, int mod, bool is_iface,
-                              string name, Parameters parameters, Attributes attrs, Location l)
+                              MemberName name, Parameters parameters, Attributes attrs,
+                              Location l)
                        : base (ds, return_type, mod,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
                                is_iface, name, attrs, parameters, l)
@@ -3664,9 +3666,9 @@ namespace Mono.CSharp {
                        }
                }
 
-               public string MethodName {
+               public MemberName MethodName {
                        get {
-                               return Name;
+                               return MemberName;
                        }
                }
 
@@ -3951,7 +3953,8 @@ namespace Mono.CSharp {
                //
                public Constructor (TypeContainer ds, string name, int mod, Parameters args,
                                    ConstructorInitializer init, Location l)
-                       : base (ds, null, mod, AllowedModifiers, false, name, null, args, l)
+                       : base (ds, null, mod, AllowedModifiers, false, new MemberName (name),
+                               null, args, l)
                {
                        Initializer = init;
                }
@@ -4235,9 +4238,9 @@ namespace Mono.CSharp {
                        }
                }
 
-               public string MethodName {
+               public MemberName MethodName {
                        get {
-                               return Name;
+                               return MemberName;
                        }
                }
 
@@ -4273,7 +4276,7 @@ namespace Mono.CSharp {
        {
                CallingConventions CallingConventions { get; }
                Location Location { get; }
-               string MethodName { get; }
+               MemberName MethodName { get; }
                Type[] ParameterTypes { get; }
                Type ReturnType { get; }
 
@@ -4333,13 +4336,8 @@ namespace Mono.CSharp {
                {
                        MethodInfo implementing = null;
 
-                       string method_name = method.MethodName;
-                       string name;
-                       if (member.IsExplicitImpl) {
-                               name = method_name.Remove (0, member.InterfaceType.FullName.Length + 1);
-                       } else {
-                               name = method_name;
-                       }
+                       string method_name = method.MethodName.GetFullName ();
+                       string name = method.MethodName.Name;
 
                        Type[] ParameterTypes = method.ParameterTypes;
 
@@ -4608,9 +4606,11 @@ namespace Mono.CSharp {
 
        public class Destructor : Method {
 
-               public Destructor (TypeContainer ds, Expression return_type, int mod, string name,
-                                  Parameters parameters, Attributes attrs, Location l)
-                       : base (ds, return_type, mod, false, name, parameters, attrs, l)
+               public Destructor (TypeContainer ds, Expression return_type, int mod,
+                                  string name, Parameters parameters, Attributes attrs,
+                                  Location l)
+                       : base (ds, return_type, mod, false, new MemberName (name),
+                               parameters, attrs, l)
                { }
 
                public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
@@ -4650,7 +4650,7 @@ namespace Mono.CSharp {
                //
                // The name of the interface we are explicitly implementing
                //
-               public string ExplicitInterfaceName = null;
+               public MemberName ExplicitInterfaceName = null;
 
                //
                // Whether this is an interface member.
@@ -4666,7 +4666,7 @@ namespace Mono.CSharp {
                // The constructor is only exposed to our children
                //
                protected MemberBase (TypeContainer parent, Expression type, int mod,
-                                     int allowed_mod, int def_mod, string name,
+                                     int allowed_mod, int def_mod, MemberName name,
                                      Attributes attrs, Location loc)
                        : base (parent, name, attrs, loc)
                {
@@ -4675,10 +4675,9 @@ namespace Mono.CSharp {
                        ModFlags = Modifiers.Check (allowed_mod, mod, def_mod, loc);
 
                        // Check for explicit interface implementation
-                       int pos = Name.LastIndexOf ('.');
-                       if (pos != -1) {
-                               ExplicitInterfaceName = Name.Substring (0, pos);
-                               ShortName = Name.Substring (pos + 1);
+                       if (MemberName.Left != null) {
+                               ExplicitInterfaceName = MemberName.Left;
+                               ShortName = MemberName.Name;
                                IsExplicitImpl = true;
                        } else
                                ShortName = Name;
@@ -4746,7 +4745,7 @@ namespace Mono.CSharp {
                protected virtual bool DoDefine ()
                {
                        if (Name == null)
-                               Name = "this";
+                               throw new InternalErrorException ();
 
                        if (IsInterface) {
                                ModFlags = Modifiers.PUBLIC |
@@ -4812,19 +4811,9 @@ namespace Mono.CSharp {
                                return false;
 
                        if (IsExplicitImpl) {
-                               int errors = Report.Errors;
-
-                               InterfaceType  = Parent.FindType (
-                                       Location, ExplicitInterfaceName);
-
-                               if (Report.Errors != errors)
-                                       return false;
-                               else if (InterfaceType == null) {
-                                       Report.Error (246, Location, "Can not find type `{0}'",
-                                               ExplicitInterfaceName);
-                                       return false;
-                               }
-
+                               InterfaceType = Parent.ResolveType (
+                                       ExplicitInterfaceName.GetTypeExpression (Location),
+                                       false, Location);
                                if (InterfaceType == null)
                                        return false;
 
@@ -4833,11 +4822,13 @@ namespace Mono.CSharp {
                                        return false;
                                }
 
+#if FIXME
                                // Compute the full name that we need to export.
                                if (InterfaceType.FullName != ExplicitInterfaceName) {
                                        ExplicitInterfaceName = InterfaceType.FullName;
                                        UpdateMemberName ();
                                }
+#endif
                                
                                if (!Parent.VerifyImplements (InterfaceType, ShortName, Name, Location))
                                        return false;
@@ -4853,10 +4844,7 @@ namespace Mono.CSharp {
                /// </summary>
                protected virtual void UpdateMemberName ()
                {
-                       if (IsExplicitImpl)
-                               Name = String.Concat (ExplicitInterfaceName, ".", ShortName);
-                       else
-                               Name = ShortName;
+                       MemberName.Name = ShortName;
                }
 
                public override string GetSignatureForError (TypeContainer tc)
@@ -4904,7 +4892,7 @@ namespace Mono.CSharp {
                // The constructor is only exposed to our children
                //
                protected FieldBase (TypeContainer parent, Expression type, int mod,
-                                    int allowed_mod, string name, object init,
+                                    int allowed_mod, MemberName name, object init,
                                     Attributes attrs, Location loc)
                        : base (parent, type, mod, allowed_mod, Modifiers.PRIVATE,
                                name, attrs, loc)
@@ -5072,8 +5060,8 @@ namespace Mono.CSharp {
 
                public Field (TypeContainer parent, Expression type, int mod, string name,
                              Object expr_or_array_init, Attributes attrs, Location loc)
-                       : base (parent, type, mod, AllowedModifiers, name, expr_or_array_init,
-                               attrs, loc)
+                       : base (parent, type, mod, AllowedModifiers, new MemberName (name),
+                               expr_or_array_init, attrs, loc)
                {
                }
 
@@ -5212,35 +5200,36 @@ namespace Mono.CSharp {
                // Field says whether accessor will be emited or not
                public readonly bool IsDummy;
 
+               protected readonly string prefix;
+
                ReturnParameter return_attributes;
 
-               public AbstractPropertyEventMethod (string name, Location loc):
-                       base (null, name, null, loc)
+               public AbstractPropertyEventMethod (MemberBase member, string prefix)
+                       : base (null, SetupName (prefix, member), null, member.Location)
                {
+                       this.prefix = prefix;
                        IsDummy = true;
                }
 
-               public AbstractPropertyEventMethod (Accessor accessor, string name):
-                       base (null, name, accessor.Attributes, accessor.Location)
+               public AbstractPropertyEventMethod (MemberBase member, Accessor accessor,
+                                                   string prefix)
+                       : base (null, SetupName (prefix, member),
+                               accessor.Attributes, accessor.Location)
                {
+                       this.prefix = prefix;
                        this.block = accessor.Block;
                }
 
-               protected static string SetupName (string prefix, MemberBase member)
+               static MemberName SetupName (string prefix, MemberBase member)
                {
-                       if (member.IsExplicitImpl) {
-                               return String.Concat (member.ExplicitInterfaceName, '.', prefix, member.ShortName);
-                       }
-
-                       return String.Concat (prefix, member.Name);
+                       MemberName name = member.MemberName.Clone ();
+                       name.Name = prefix + member.ShortName;
+                       return name;
                }
 
                public void UpdateName (MemberBase member)
                {
-                       int start = Name.LastIndexOf ('.');
-                       start++;
-                       string prefix = Name.Substring (start, (Name.LastIndexOf ('_') + 1) - start);
-                       base.Name = SetupName (prefix, member);
+                       MemberName.Name = prefix + member.ShortName;
                }
 
                #region IMethodData Members
@@ -5266,9 +5255,9 @@ namespace Mono.CSharp {
                        return false;
                }
 
-               public string MethodName {
+               public MemberName MethodName {
                        get {
-                               return Name;
+                               return MemberName;
                        }
                }
 
@@ -5479,14 +5468,15 @@ namespace Mono.CSharp {
                {
                        protected readonly MethodCore method;
 
-                       public PropertyMethod (MethodCore method, string prefix):
-                               base (SetupName (prefix, method), method.Location)
+                       public PropertyMethod (MethodCore method, string prefix)
+                               : base (method, prefix)
                        {
                                this.method = method;
                        }
 
-                       public PropertyMethod (MethodCore method, Accessor accessor, string prefix):
-                               base (accessor, SetupName (prefix, method))
+                       public PropertyMethod (MethodCore method, Accessor accessor,
+                                              string prefix)
+                               : base (method, accessor, prefix)
                        {
                                this.method = method;
                        }
@@ -5544,7 +5534,7 @@ namespace Mono.CSharp {
                protected EmitContext ec;
 
                public PropertyBase (TypeContainer ds, Expression type, int mod_flags,
-                                    int allowed_mod, bool is_iface, string name,
+                                    int allowed_mod, bool is_iface, MemberName name,
                                     Parameters parameters, Attributes attrs,
                                     Location loc)
                        : base (ds, type, mod_flags, allowed_mod, is_iface, name,
@@ -5700,7 +5690,7 @@ namespace Mono.CSharp {
                        Modifiers.NEW;
 
                public Property (TypeContainer ds, Expression type, int mod, bool is_iface,
-                                string name, Attributes attrs, Accessor get_block,
+                                MemberName name, Attributes attrs, Accessor get_block,
                                 Accessor set_block, Location loc)
                        : base (ds, type, mod,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
@@ -5937,7 +5927,7 @@ namespace Mono.CSharp {
                static string[] attribute_targets = new string [] { "event", "property" };
 
                public EventProperty (TypeContainer parent, Expression type, int mod_flags,
-                                     bool is_iface, string name, Object init,
+                                     bool is_iface, MemberName name, Object init,
                                      Attributes attrs, Accessor add, Accessor remove,
                                      Location loc)
                        : base (parent, type, mod_flags, is_iface, name, init, attrs, loc)
@@ -5961,7 +5951,7 @@ namespace Mono.CSharp {
                static string[] attribute_targets = new string [] { "event", "field", "method" };
 
                public EventField (TypeContainer parent, Expression type, int mod_flags,
-                                  bool is_iface, string name, Object init,
+                                  bool is_iface, MemberName name, Object init,
                                   Attributes attrs, Location loc)
                        : base (parent, type, mod_flags, is_iface, name, init, attrs, loc)
                {
@@ -6042,14 +6032,14 @@ namespace Mono.CSharp {
 
                        static string[] attribute_targets = new string [] { "method", "param", "return" };
 
-                       public DelegateMethod (Event method, string prefix):
-                               base (SetupName (prefix, method), method.Location)
+                       public DelegateMethod (Event method, string prefix)
+                               : base (method, prefix)
                        {
                                this.method = method;
                        }
 
-                       public DelegateMethod (Event method, Accessor accessor, string prefix):
-                               base (accessor, SetupName (prefix, method))
+                       public DelegateMethod (Event method, Accessor accessor, string prefix)
+                               : base (method, accessor, prefix)
                        {
                                this.method = method;
                        }
@@ -6183,7 +6173,7 @@ namespace Mono.CSharp {
                public MethodBuilder AddBuilder, RemoveBuilder;
 
                public Event (TypeContainer parent, Expression type, int mod_flags,
-                             bool is_iface, string name, Object init, Attributes attrs,
+                             bool is_iface, MemberName name, Object init, Attributes attrs,
                              Location loc)
                        : base (parent, type, mod_flags,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
@@ -6409,12 +6399,12 @@ namespace Mono.CSharp {
                        Modifiers.NEW;
 
 
-               public Indexer (TypeContainer ds, Expression type, string int_type, int mod,
+               public Indexer (TypeContainer ds, Expression type, MemberName name, int mod,
                                bool is_iface, Parameters parameters, Attributes attrs,
                                Accessor get_block, Accessor set_block, Location loc)
                        : base (ds, type, mod,
                                is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
-                               is_iface, int_type, parameters, attrs, loc)
+                               is_iface, name, parameters, attrs, loc)
                {
                        if (get_block == null)
                                Get = new GetIndexerMethod (this);
@@ -6618,8 +6608,8 @@ namespace Mono.CSharp {
                public Operator (TypeContainer parent, OpType type, Expression ret_type,
                                 int mod_flags, Parameters parameters,
                                 Block block, Attributes attrs, Location loc)
-                       : base (parent, ret_type, mod_flags, AllowedModifiers, false, "op_" + type,
-                               attrs, parameters, loc)
+                       : base (parent, ret_type, mod_flags, AllowedModifiers, false,
+                               new MemberName ("op_" + type), attrs, parameters, loc)
                {
                        OperatorType = type;
                        Block = block;
@@ -6679,9 +6669,8 @@ namespace Mono.CSharp {
                                return false;
 
                        OperatorMethod = new Method (
-                               Parent, Type, ModFlags, false, Name,
-                               Parameters,
-                               OptAttributes, Location);
+                               Parent, Type, ModFlags, false, MemberName,
+                               Parameters, OptAttributes, Location);
 
                        OperatorMethod.Block = Block;
                        OperatorMethod.IsOperator = true;                       
index 39b39a7715795d45f172cc7235b1cb874248b453..e74283d6e22f71cf8786000744d7c199800973ee 100755 (executable)
@@ -43,8 +43,8 @@ namespace Mono.CSharp {
 
                public Const (TypeContainer parent, Expression constant_type, string name,
                              Expression expr, int mod_flags, Attributes attrs, Location loc)
-                       : base (parent, constant_type, mod_flags, AllowedModifiers, name,
-                               null, attrs, loc)
+                       : base (parent, constant_type, mod_flags, AllowedModifiers,
+                               new MemberName (name), null, attrs, loc)
                {
                        Expr = expr;
                }
index 999ffc4f25ad97ac0c6f99f110d0462830106a63..c1095e1501032a7f5f890c56758163517ed8b8fc 100755 (executable)
@@ -312,7 +312,7 @@ using_alias_directive
        : USING IDENTIFIER ASSIGN 
          namespace_or_type_name SEMICOLON
          {
-                 current_namespace.UsingAlias ((string) $2, (Expression) $4, lexer.Location);
+               current_namespace.UsingAlias ((string) $2, (MemberName) $4, lexer.Location);
          }
        | USING error {
                CheckIdentifierToken (yyToken);
@@ -338,14 +338,17 @@ namespace_declaration
                        Report.Error(1518, Lexer.Location, "Attributes cannot be applied to namespaces."
                                        + " Expected class, delegate, enum, interface, or struct");
                }
-               
-               if (current_namespace.Parent != null && $3 is MemberAccess) {
-                       // Cannot use qualified namespace names in nested namespace declarations
-                       Report.Error (134, lexer.Location, "Cannot use qualified namespace names in nested namespace declarations");
+
+               MemberName name = (MemberName) $3;
+
+               if ((current_namespace.Parent != null) && (name.Left != null)) {
+                       Report.Error (134, lexer.Location,
+                                     "Cannot use qualified namespace names in nested " +
+                                     "namespace declarations");
                }
 
                current_namespace = new NamespaceEntry (
-                       current_namespace, file, $3.ToString (), lexer.Location);
+                       current_namespace, file, name.GetName (false), lexer.Location);
          } 
          namespace_body opt_semicolon
          { 
@@ -364,7 +367,11 @@ opt_comma
        ;
 
 namespace_name
-       : namespace_or_type_name { $$ = ($1).ToString (); } 
+       : namespace_or_type_name {
+               MemberName name = (MemberName) $1;
+
+               $$ = name.GetName (false);
+         }
        ;
 
 namespace_body
@@ -581,7 +588,7 @@ attribute
        ;
 
 attribute_name
-       : type_name  { /* reserved attribute name or identifier: 17.4 */ }
+       : namespace_or_type_name  { /* reserved attribute name or identifier: 17.4 */ }
        ;
 
 opt_attribute_arguments
@@ -705,9 +712,9 @@ struct_declaration
        : opt_attributes
          opt_modifiers
          opt_partial
-         STRUCT IDENTIFIER
+         STRUCT member_name
          { 
-               string name = MakeName ((string) $5);
+               MemberName name = MakeName ((MemberName) $5);
                bool partial = (bool) $3;
 
                if (partial) {
@@ -723,7 +730,7 @@ struct_declaration
                                (Attributes) $1, lexer.Location);
 
                        current_container = current_class;
-                       RootContext.Tree.RecordDecl (name, current_class);
+                       RootContext.Tree.RecordDecl (name.GetName (true), current_class);
                }
          }
          opt_class_base
@@ -953,13 +960,14 @@ opt_error_modifier
 method_header
        : opt_attributes
          opt_modifiers
-         type
-         member_name
+         type namespace_or_type_name
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS 
          {
+               MemberName name = (MemberName) $4;
+
                Method method = new Method (current_class, (Expression) $3, (int) $2,
-                                           false, (string) $4,  (Parameters) $6,
-                                           (Attributes) $1, lexer.Location);
+                                           false, name,  (Parameters) $6, (Attributes) $1,
+                                           lexer.Location);
 
                current_local_parameters = (Parameters) $6;
 
@@ -967,12 +975,13 @@ method_header
          }
        | opt_attributes
          opt_modifiers
-         VOID
-         member_name
+         VOID namespace_or_type_name
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS 
          {
+               MemberName name = (MemberName) $4;
+
                Method method = new Method (current_class, TypeManager.system_void_expr,
-                                           (int) $2, false, (string) $4, (Parameters) $6,
+                                           (int) $2, false, name, (Parameters) $6,
                                            (Attributes) $1, lexer.Location);
 
                current_local_parameters = (Parameters) $6;
@@ -981,14 +990,16 @@ method_header
        | opt_attributes
          opt_modifiers
          type 
-         modifiers member_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
+         modifiers namespace_or_type_name OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
          {
                Report.Error (1585, lexer.Location, 
                        String.Format ("Modifier {0} should appear before type", 
                                Modifiers.Name ((int) $4)));
+               MemberName name = (MemberName) $4;
+
                Method method = new Method (current_class, TypeManager.system_void_expr,
-                                           0, false, (string) $5, (Parameters) $7,
-                                           (Attributes) $1, lexer.Location);
+                                           0, false, name, (Parameters) $7, (Attributes) $1,
+                                           lexer.Location);
 
                current_local_parameters = (Parameters) $7;
                $$ = method;
@@ -1119,14 +1130,10 @@ parameter_array
          }
        ;
 
-member_name 
-       : namespace_or_type_name { $$ = ($1).ToString (); } 
-       ;
-
 property_declaration
        : opt_attributes
          opt_modifiers
-         type member_name
+         type namespace_or_type_name
          OPEN_BRACE 
          {
                implicit_value_parameter_type = (Expression) $3;
@@ -1149,8 +1156,10 @@ property_declaration
                Accessor set_block = (Accessor) pair.Second;
 
                Location loc = (Location) $6;
+               MemberName name = (MemberName) $4;
+
                prop = new Property (current_class, (Expression) $3, (int) $2, false,
-                                    (string) $4, (Attributes) $1, get_block, set_block, loc);
+                                    name, (Attributes) $1, get_block, set_block, loc);
                if (SimpleIteratorContainer.Simple.Yields)
                        prop.SetYields ();
                
@@ -1246,9 +1255,9 @@ interface_declaration
        : opt_attributes
          opt_modifiers
          opt_partial
-         INTERFACE IDENTIFIER
+         INTERFACE member_name
          {
-               string name = MakeName ((string) $5);
+               MemberName name = MakeName ((MemberName) $5);
                bool partial = (bool) $3;
 
                if (partial) {
@@ -1264,7 +1273,7 @@ interface_declaration
                                (Attributes) $1, lexer.Location);
 
                        current_container = current_class;
-                       RootContext.Tree.RecordDecl (name, current_class);
+                       RootContext.Tree.RecordDecl (name.GetName (true), current_class);
                }
          }
          opt_class_base
@@ -1340,21 +1349,23 @@ opt_new
        ;
 
 interface_method_declaration
-       : opt_attributes opt_new type IDENTIFIER 
+       : opt_attributes opt_new type namespace_or_type_name
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
          SEMICOLON
          {
+               MemberName name = (MemberName) $4;
+
                $$ = new Method (current_class, (Expression) $3, (int) $2, true,
-                                (string) $4, (Parameters) $6, (Attributes) $1,
-                                lexer.Location);
+                                name, (Parameters) $6, (Attributes) $1, lexer.Location);
          }
-       | opt_attributes opt_new VOID IDENTIFIER 
+       | opt_attributes opt_new VOID namespace_or_type_name
          OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
          SEMICOLON
          {
+               MemberName name = (MemberName) $4;
+
                $$ = new Method (current_class, TypeManager.system_void_expr, (int) $2,
-                                true, (string) $4, (Parameters) $6,  (Attributes) $1,
-                                lexer.Location);
+                                true, name, (Parameters) $6,  (Attributes) $1, lexer.Location);
          }
        ;
 
@@ -1371,8 +1382,8 @@ interface_property_declaration
                 InterfaceAccessorInfo pinfo = (InterfaceAccessorInfo) $7;
 
                $$ = new Property (current_class, (Expression) $3, (int) $2, true,
-                                  (string) $4, (Attributes) $1, pinfo.Get, pinfo.Set,
-                                  lexer.Location);
+                                  new MemberName ((string) $4), (Attributes) $1,
+                                  pinfo.Get, pinfo.Set, lexer.Location);
          }
        | opt_attributes
          opt_new
@@ -1394,8 +1405,9 @@ interface_accessors
 interface_event_declaration
        : opt_attributes opt_new EVENT type IDENTIFIER SEMICOLON
          {
-               $$ = new EventField (current_class, (Expression) $4, (int) $2, true, (string) $5, null,
-                               (Attributes) $1, lexer.Location);
+               $$ = new EventField (current_class, (Expression) $4, (int) $2, true,
+                                    new MemberName ((string) $5), null,
+                                    (Attributes) $1, lexer.Location);
          }
        | opt_attributes opt_new EVENT type error {
                CheckIdentifierToken (yyToken);
@@ -1422,9 +1434,10 @@ interface_indexer_declaration
          {
                InterfaceAccessorInfo info = (InterfaceAccessorInfo) $10;
 
-               $$ = new Indexer (current_class, (Expression) $3, TypeContainer.DefaultIndexerName, (int) $2, true,
-                                 (Parameters) $6, (Attributes) $1, info.Get, info.Set,
-                                 lexer.Location);
+               $$ = new Indexer (current_class, (Expression) $3,
+                                 new MemberName (TypeContainer.DefaultIndexerName),
+                                 (int) $2, true, (Parameters) $6, (Attributes) $1,
+                                 info.Get, info.Set, lexer.Location);
          }
        ;
 
@@ -1703,9 +1716,12 @@ event_declaration
          {
                foreach (VariableDeclaration var in (ArrayList) $5) {
 
-                       Event e = new EventField (current_class, (Expression) $4, (int) $2, false, var.identifier,
-                                            var.expression_or_array_initializer,
-                                            (Attributes) $1, lexer.Location);
+                       MemberName name = new MemberName (var.identifier);
+
+                       Event e = new EventField (
+                               current_class, (Expression) $4, (int) $2, false, name,
+                               var.expression_or_array_initializer, (Attributes) $1,
+                               lexer.Location);
 
                        current_container.AddEvent (e);
                                       
@@ -1713,7 +1729,7 @@ event_declaration
          }
        | opt_attributes
          opt_modifiers
-         EVENT type member_name
+         EVENT type namespace_or_type_name
          OPEN_BRACE
          {
                implicit_value_parameter_type = (Expression) $4;  
@@ -1734,9 +1750,12 @@ event_declaration
                } else {
                        Pair pair = (Pair) $8;
                        
-                       Event e = new EventProperty (current_class, (Expression) $4, (int) $2, false, (string) $5,
-                                            null, (Attributes) $1, (Accessor) pair.First, (Accessor) pair.Second,
-                                            loc);
+                       MemberName name = (MemberName) $5;
+
+                       Event e = new EventProperty (
+                               current_class, (Expression) $4, (int) $2, false, name, null,
+                               (Attributes) $1, (Accessor) pair.First, (Accessor) pair.Second,
+                               loc);
                        
                        current_container.AddEvent (e);
                        implicit_value_parameter_type = null;
@@ -1842,10 +1861,13 @@ indexer_declaration
                Pair pair = (Pair) $6;
                Accessor get_block = (Accessor) pair.First;
                Accessor set_block = (Accessor) pair.Second;
-               string name = decl.interface_type;
-               if (name != null)
-                       name += ".";
-               name += TypeContainer.DefaultIndexerName;
+
+               MemberName name;
+               if (decl.interface_type != null)
+                       name = new MemberName (decl.interface_type,
+                                              TypeContainer.DefaultIndexerName);
+               else
+                       name = new MemberName (TypeContainer.DefaultIndexerName);
 
                indexer = new Indexer (current_class, decl.type, name,
                                       (int) $2, false, decl.param_list, (Attributes) $1,
@@ -1885,7 +1907,8 @@ indexer_declarator
                } else if (pars.FixedParameters == null && pars.ArrayParameter == null){
                        Report.Error (1551, lexer.Location, "Indexers must have at least one parameter");
                }
-               $$ = new IndexerDeclaration ((Expression) $1, $2.ToString (), pars);
+               MemberName name = (MemberName) $2;
+               $$ = new IndexerDeclaration ((Expression) $1, name, pars);
          }
        ;
 
@@ -1899,7 +1922,7 @@ enum_declaration
          { 
                Location enum_location = lexer.Location;
 
-               string full_name = MakeName ((string) $4);
+               MemberName full_name = MakeName (new MemberName ((string) $4));
                Enum e = new Enum (current_namespace, current_container, (Expression) $5, (int) $2,
                                   full_name, (Attributes) $1, enum_location);
                
@@ -1909,8 +1932,9 @@ enum_declaration
                                                   ev.Location, ev.OptAttributes);
                }
 
+               string name = full_name.GetName (false);
                current_container.AddEnum (e);
-               RootContext.Tree.RecordDecl (full_name, e);
+               RootContext.Tree.RecordDecl (name, e);
 
          }
        ;
@@ -1968,48 +1992,46 @@ enum_member_declaration
 delegate_declaration
        : opt_attributes
          opt_modifiers
-         DELEGATE type   
-         IDENTIFIER OPEN_PARENS 
-         opt_formal_parameter_list
-         CLOSE_PARENS 
+         DELEGATE type member_name
+         OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS 
          SEMICOLON
          {
                Location l = lexer.Location;
-               string name = MakeName ((string) $5);
+               MemberName name = MakeName ((MemberName) $5);
                Delegate del = new Delegate (current_namespace, current_container, (Expression) $4,
                                             (int) $2, name, (Parameters) $7, (Attributes) $1, l);
 
                current_container.AddDelegate (del);
-               RootContext.Tree.RecordDecl (name, del);
+               RootContext.Tree.RecordDecl (name.GetName (false), del);
          }     
        | opt_attributes
          opt_modifiers
-         DELEGATE VOID   
-         IDENTIFIER OPEN_PARENS 
-         opt_formal_parameter_list
-         CLOSE_PARENS 
+         DELEGATE VOID member_name
+         OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS 
          SEMICOLON
          {
                Location l = lexer.Location;
-               string name = MakeName ((string) $5);
+               MemberName name = MakeName ((MemberName) $5);
                Delegate del = new Delegate (
                        current_namespace, current_container,
                        TypeManager.system_void_expr, (int) $2, name,
                        (Parameters) $7, (Attributes) $1, l);
 
                current_container.AddDelegate (del);
-               RootContext.Tree.RecordDecl (name, del);
+               RootContext.Tree.RecordDecl (name.GetName (false), del);
          }
        ;
 
-type_name
-       : namespace_or_type_name
+namespace_or_type_name
+       : member_name
+       | namespace_or_type_name DOT IDENTIFIER {
+               $$ = new MemberName ((MemberName) $1, (string) $3);
+         }
        ;
 
-namespace_or_type_name
-       : IDENTIFIER { $$ = new SimpleName ((string) $1, lexer.Location);}
-       | namespace_or_type_name DOT IDENTIFIER { 
-               $$ = new MemberAccess ((Expression) $1, (string) $3, lexer.Location);
+member_name
+       : IDENTIFIER {
+               $$ = new MemberName ((string) $1);
          }
        ;
 
@@ -2020,11 +2042,9 @@ namespace_or_type_name
  * gets rid of a shift/reduce couple
  */
 type
-       : type_name {   /* class_type */
-               /* 
-                  This does interfaces, delegates, struct_types, class_types, 
-                  parent classes, and more! 4.2 
-                */
+       : namespace_or_type_name
+         {
+               $$ = ((MemberName) $1).GetTypeExpression (lexer.Location);
          }
        | builtin_types
        | array_type
@@ -2121,10 +2141,6 @@ integral_type
        | VOID          { $$ = TypeManager.system_void_expr; }
        ;
 
-interface_type
-       : type_name
-       ;
-
 array_type
        : type rank_specifiers
          {
@@ -2141,7 +2157,10 @@ primary_expression
                // 7.5.1: Literals
          }
  
-       | IDENTIFIER { $$ = new SimpleName ((string) $1, lexer.Location); }
+       | member_name
+         {
+               $$ = ((MemberName) $1).GetTypeExpression (lexer.Location);
+         }
        | parenthesized_expression
        | member_access
        | invocation_expression
@@ -2946,9 +2965,9 @@ class_declaration
        : opt_attributes
          opt_modifiers
          opt_partial
-         CLASS IDENTIFIER
+         CLASS member_name
          {
-               string name = MakeName ((string) $5);
+               MemberName name = MakeName ((MemberName) $5);
                bool partial = (bool) $3;
                int mod_flags = (int) $2;
 
@@ -2968,7 +2987,7 @@ class_declaration
                                                (Attributes) $1, lexer.Location);
                        }
                        current_container = current_class;
-                       RootContext.Tree.RecordDecl (name, current_class);
+                       RootContext.Tree.RecordDecl (name.GetName (false), current_class);
                }
          }
          opt_class_base
@@ -4095,10 +4114,11 @@ public class InterfaceAccessorInfo {
 // </summary>
 public class IndexerDeclaration {
        public Expression type;
-       public string interface_type;
+       public MemberName interface_type;
        public Parameters param_list;
 
-       public IndexerDeclaration (Expression type, string interface_type, Parameters param_list)
+       public IndexerDeclaration (Expression type, MemberName interface_type,
+                                  Parameters param_list)
        {
                this.type = type;
                this.interface_type = interface_type;
@@ -4162,19 +4182,19 @@ void Error_ExpectingTypeName (Location l, Expression expr)
 //   Given the @class_name name, it creates a fully qualified name
 //   based on the containing declaration space
 // </summary>
-string 
-MakeName (string class_name)
+MemberName
+MakeName (MemberName class_name)
 {
        string ns = current_namespace.FullName;
-       string container_name = current_container.Name;
 
-       if (container_name == ""){
+       if (current_container.Name == ""){
                if (ns != "")
-                       return ns + "." + class_name;
+                       return new MemberName (new MemberName (ns), class_name);
                else
                        return class_name;
-       } else
-               return container_name + "." + class_name;
+       } else {
+               return new MemberName (current_container.MemberName, class_name);
+       }
 }
 
 Block declare_local_variables (Expression type, ArrayList variable_declarators, Location loc)
index aaa4cf84c7efb13f58a24799d9ac0f17ee2109cf..6c2ede4b0ad6221c37f75e51b1098017f5feb48e 100755 (executable)
@@ -19,6 +19,84 @@ using System.Reflection;
 
 namespace Mono.CSharp {
 
+       public class MemberName {
+               public string Name;
+               public readonly MemberName Left;
+
+               public static readonly MemberName Null = new MemberName ("");
+
+               public MemberName (string name)
+               {
+                       this.Name = name;
+               }
+
+               public MemberName (MemberName left, string name)
+                       : this (name)
+               {
+                       this.Left = left;
+               }
+
+               public MemberName (MemberName left, MemberName right)
+                       : this (left, right.Name)
+               {
+               }
+
+               public string GetName (bool is_generic)
+               {
+                       string name = is_generic ? Basename : Name;
+                       if (Left != null)
+                               return Left.GetName (is_generic) + "." + name;
+                       else
+                               return name;
+               }
+
+               public string GetFullName ()
+               {
+                       if (Left != null)
+                               return Left.GetFullName () + "." + Name;
+                       else
+                               return Name;
+               }
+
+               public string GetTypeName ()
+               {
+                       if (Left != null)
+                               return Left.GetTypeName () + "." + Name;
+                       else
+                               return Name;
+               }
+
+               public Expression GetTypeExpression (Location loc)
+               {
+                       if (Left != null) {
+                               Expression lexpr = Left.GetTypeExpression (loc);
+
+                               return new MemberAccess (lexpr, Name, loc);
+                       } else {
+                               return new SimpleName (Name, loc);
+                       }
+               }
+
+               public MemberName Clone ()
+               {
+                       if (Left != null)
+                               return new MemberName (Left.Clone (), Name);
+                       else
+                               return new MemberName (Name);
+               }
+
+               public string Basename {
+                       get {
+                               return Name;
+                       }
+               }
+
+               public override string ToString ()
+               {
+                       return GetFullName ();
+               }
+       }
+
        /// <summary>
        ///   Base representation for members.  This is used to keep track
        ///   of Name, Location and Modifier flags, and handling Attributes.
@@ -27,7 +105,14 @@ namespace Mono.CSharp {
                /// <summary>
                ///   Public name
                /// </summary>
-               public string Name;
+               public string Name {
+                       get {
+                               // !(this is GenericMethod) && !(this is Method)
+                               return MemberName.GetName (false);
+                       }
+               }
+
+               public readonly MemberName MemberName;
 
                /// <summary>
                ///   Modifier flags that the user specified in the source code
@@ -61,12 +146,12 @@ namespace Mono.CSharp {
                /// </summary>
                internal Flags caching_flags;
 
-               public MemberCore (TypeContainer parent, string name, Attributes attrs,
+               public MemberCore (TypeContainer parent, MemberName name, Attributes attrs,
                                   Location loc)
                        : base (attrs)
                {
                        Parent = parent;
-                       Name = name;
+                       MemberName = name;
                        Location = loc;
                        caching_flags = Flags.Obsolete_Undetected | Flags.ClsCompliance_Undetected | Flags.HasCompliantAttribute_Undetected | Flags.Excluded_Undetected;
                }
@@ -290,11 +375,12 @@ namespace Mono.CSharp {
 
                static string[] attribute_targets = new string [] { "type" };
 
-               public DeclSpace (NamespaceEntry ns, TypeContainer parent, string name, Attributes attrs, Location l)
+               public DeclSpace (NamespaceEntry ns, TypeContainer parent, MemberName name,
+                                 Attributes attrs, Location l)
                        : base (parent, name, attrs, l)
                {
                        NamespaceEntry = ns;
-                       Basename = name.Substring (1 + name.LastIndexOf ('.'));
+                       Basename = name.Name;
                        defined_names = new Hashtable ();
                }
 
@@ -330,7 +416,7 @@ namespace Mono.CSharp {
                public void RecordDecl ()
                {
                        if ((NamespaceEntry != null) && (Parent == RootContext.Tree.Types))
-                               NamespaceEntry.DefineName (Basename, this);
+                               NamespaceEntry.DefineName (MemberName.Basename, this);
                }
 
                /// <summary>
index f71a8c7fa7b5ec55f9527809c0416367e66c2db3..df97ef01ed99c52222cf8b01cb260d5546b06984 100644 (file)
@@ -49,7 +49,7 @@ namespace Mono.CSharp {
                        Modifiers.PRIVATE;
 
                public Delegate (NamespaceEntry ns, TypeContainer parent, Expression type,
-                                int mod_flags, string name, Parameters param_list,
+                                int mod_flags, MemberName name, Parameters param_list,
                                 Attributes attrs, Location l)
                        : base (ns, parent, name, attrs, l)
 
index b40a23ea1d20425106187e0f24f76ba09dde04ea..2511ec62312131e71875431bda272fb6e66bf154 100755 (executable)
@@ -24,8 +24,9 @@ namespace Mono.CSharp {
                public FieldBuilder builder;
                internal readonly Expression Type;
 
-               public EnumMember (Enum parent_enum, Expression expr, string name, Location loc, Attributes attrs):
-                       base (null, name, attrs, loc)
+               public EnumMember (Enum parent_enum, Expression expr, string name,
+                                  Location loc, Attributes attrs):
+                       base (null, new MemberName (name), attrs, loc)
                {
                        this.parent_enum = parent_enum;
                        this.ModFlags = parent_enum.ModFlags;
@@ -131,8 +132,8 @@ namespace Mono.CSharp {
                        Modifiers.INTERNAL |
                        Modifiers.PRIVATE;
 
-               public Enum (NamespaceEntry ns, TypeContainer parent, Expression type, int mod_flags,
-                            string name, Attributes attrs, Location l)
+               public Enum (NamespaceEntry ns, TypeContainer parent, Expression type,
+                            int mod_flags, MemberName name, Attributes attrs, Location l)
                        : base (ns, parent, name, attrs, l)
                {
                        this.BaseType = type;
index d28b81060d10c73981dcf74fbc1b657f2c000eb6..abfd159a130ce09fbef5a129bd13b94294ebf656 100644 (file)
@@ -335,13 +335,13 @@ namespace Mono.CSharp {
                        point.Define (ig);
                }
 
-               private static string MakeProxyName (string name)
+               private static MemberName MakeProxyName (string name)
                {
                        int pos = name.LastIndexOf ('.');
                        if (pos > 0)
                                name = name.Substring (pos + 1);
 
-                       return "<" + name + ">__" + (proxy_count++);
+                       return new MemberName ("<" + name + ">__" + (proxy_count++));
                }
 
                //
@@ -576,6 +576,9 @@ namespace Mono.CSharp {
 
                void Define_Current ()
                {
+                       MemberName left = new MemberName ("System.Collections.IEnumerator");
+                       MemberName name = new MemberName (left, "Current");
+
                        Block get_block = new Block (null);
 
                        get_block.AddStatement (new If (
@@ -591,8 +594,8 @@ namespace Mono.CSharp {
                        Accessor getter = new Accessor (get_block, null, Location);
 
                        Property current = new Property (
-                               this, iterator_type_expr, Modifiers.PUBLIC,
-                               false, "Current", null, getter, null, Location);
+                               this, iterator_type_expr, 0,
+                               false, name, null, getter, null, Location);
                        AddProperty (current);
                }
 
@@ -600,7 +603,7 @@ namespace Mono.CSharp {
                {
                        Method move_next = new Method (
                                this, TypeManager.system_boolean_expr,
-                               Modifiers.PUBLIC, false, "MoveNext",
+                               Modifiers.PUBLIC, false, new MemberName ("MoveNext"),
                                Parameters.EmptyReadOnlyParameters, null,
                                Location.Null);
                        AddMethod (move_next);
@@ -613,10 +616,13 @@ namespace Mono.CSharp {
 
                void Define_GetEnumerator ()
                {
+                       MemberName left = new MemberName ("System.Collections.IEnumerable");
+                       MemberName name = new MemberName (left, "GetEnumerator");
+
                        Method get_enumerator = new Method (
                                this,
                                new TypeExpression (TypeManager.ienumerator_type, Location),
-                               Modifiers.PUBLIC, false, "GetEnumerator",
+                               0, false, name,
                                Parameters.EmptyReadOnlyParameters, null,
                                Location.Null);
                        AddMethod (get_enumerator);
@@ -834,8 +840,8 @@ namespace Mono.CSharp {
                {
                        Method reset = new Method (
                                this, TypeManager.system_void_expr, Modifiers.PUBLIC,
-                               false, "Reset", Parameters.EmptyReadOnlyParameters,
-                               null, Location);
+                               false, new MemberName ("Reset"),
+                               Parameters.EmptyReadOnlyParameters, null, Location);
                        AddMethod (reset);
 
                        reset.Block = new Block (null);
@@ -846,8 +852,8 @@ namespace Mono.CSharp {
                {
                        dispose = new Method (
                                this, TypeManager.system_void_expr, Modifiers.PUBLIC,
-                               false, "Dispose", Parameters.EmptyReadOnlyParameters,
-                               null, Location);
+                               false, new MemberName ("Dispose"),
+                               Parameters.EmptyReadOnlyParameters, null, Location);
                        AddMethod (dispose);
 
                        dispose.Block = new Block (null);
index 8fd5217da6b34b0d47c7aa9d307b63c9006b5a0b..0695ef0d3b5a0d589e21d1618a6af20a84c42042 100755 (executable)
@@ -231,11 +231,11 @@ namespace Mono.CSharp {
 
                public class AliasEntry {
                        public readonly string Name;
-                       public readonly Expression Alias;
+                       public readonly MemberName Alias;
                        public readonly NamespaceEntry NamespaceEntry;
                        public readonly Location Location;
                        
-                       public AliasEntry (NamespaceEntry entry, string name, Expression alias, Location loc)
+                       public AliasEntry (NamespaceEntry entry, string name, MemberName alias, Location loc)
                        {
                                Name = name;
                                Alias = alias;
@@ -353,7 +353,7 @@ namespace Mono.CSharp {
                        using_clauses.Add (ue);
                }
 
-               public void UsingAlias (string alias, Expression namespace_or_type, Location loc)
+               public void UsingAlias (string name, MemberName alias, Location loc)
                {
                        if (DeclarationFound){
                                Report.Error (1529, loc, "A using clause must precede all other namespace elements");
@@ -363,13 +363,13 @@ namespace Mono.CSharp {
                        if (aliases == null)
                                aliases = new Hashtable ();
                        
-                       if (aliases.Contains (alias)){
-                               Report.Error (1537, loc, "The using alias `" + alias +
+                       if (aliases.Contains (name)){
+                               Report.Error (1537, loc, "The using alias `" + name +
                                              "' appeared previously in this namespace");
                                return;
                        }
 
-                       aliases [alias] = new AliasEntry (this, alias, namespace_or_type, loc);
+                       aliases [name] = new AliasEntry (this, name, alias, loc);
                }
 
                protected AliasEntry GetAliasEntry (string alias)
index 5aaea422cb121888f609daa7d7b5ae5d7521e224..c873e706fe3b72bfb6c213e0d1a53472b167ad38 100755 (executable)
@@ -111,7 +111,8 @@ namespace Mono.CSharp
        public class RootTypes : TypeContainer
        {
                public RootTypes ()
-                       : base (null, null, "", null, Kind.Root, new Location (-1))
+                       : base (null, null, MemberName.Null, null, Kind.Root,
+                               new Location (-1))
                { }
 
                public override void Register ()