2004-04-05 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Mon, 5 Apr 2004 23:34:55 +0000 (23:34 -0000)
committerMartin Baulig <martin@novell.com>
Mon, 5 Apr 2004 23:34:55 +0000 (23:34 -0000)
* decl.cs (MemberCore): For generic classes, interfaces and
structs, `Name' now includes the number of type parameters
("Stack!1.Node!1").
(DeclSpace.FindType): Removed the `num_type_args' argument; we now
encode the number of type arguments in the type name.

* expression.cs (Expression.MemberLookup): Removed the
`num_type_args' argument; we now encode the number of type
arguments in the type name.

* ecore.cs (SimpleName): Encode the number of type arguments in
the type name itself.

* generic.cs (ConstructedType): Likewise.

* tree.cs (Tree.RecordDecl): Take a `string' instead of a
`MemberName'; we now include the number of type parameters in the
type name.

* typemanager.cs (TypeManager.CheckGeneric): Removed.
(TypeManager.MemberLookup): Removed the
`num_type_args' argument; we now encode the number of type
arguments in the type name.

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

mcs/gmcs/ChangeLog
mcs/gmcs/class.cs
mcs/gmcs/cs-parser.jay
mcs/gmcs/decl.cs
mcs/gmcs/ecore.cs
mcs/gmcs/expression.cs
mcs/gmcs/generic.cs
mcs/gmcs/namespace.cs
mcs/gmcs/tree.cs
mcs/gmcs/typemanager.cs

index 24bf7a7f35d36dae17f7b0d7fa5b7aba90c776bc..d86f826fd5b4a7746bf4bc4cf9cc51a70771c7b9 100755 (executable)
@@ -1,3 +1,29 @@
+2004-04-05  Martin Baulig  <martin@ximian.com>
+
+       * decl.cs (MemberCore): For generic classes, interfaces and
+       structs, `Name' now includes the number of type parameters
+       ("Stack!1.Node!1").
+       (DeclSpace.FindType): Removed the `num_type_args' argument; we now
+       encode the number of type arguments in the type name.
+
+       * expression.cs (Expression.MemberLookup): Removed the
+       `num_type_args' argument; we now encode the number of type
+       arguments in the type name.
+
+       * ecore.cs (SimpleName): Encode the number of type arguments in
+       the type name itself.
+
+       * generic.cs (ConstructedType): Likewise.
+
+       * tree.cs (Tree.RecordDecl): Take a `string' instead of a
+       `MemberName'; we now include the number of type parameters in the
+       type name.
+
+       * typemanager.cs (TypeManager.CheckGeneric): Removed.
+       (TypeManager.MemberLookup): Removed the
+       `num_type_args' argument; we now encode the number of type
+       arguments in the type name.     
+
 2004-04-03  Martin Baulig  <martin@ximian.com>
 
        * decl.cs (MemberCore.ctor): Take a MemberName instead of a sting.
index dd3ddeb618886dd017ef902ea8ec8ac4cdaba01b..424127dc64f381c102a979d1f07a57a9b613cc6f 100755 (executable)
@@ -885,7 +885,7 @@ namespace Mono.CSharp {
                                }
                                
                                TypeBuilder = builder.DefineNestedType (
-                                       Basename, type_attributes, ptype, null);
+                                       MemberName.Basename, type_attributes, ptype, null);
                        }
 
                        TypeManager.AddUserType (Name, TypeBuilder, this, ifaces);
@@ -3105,7 +3105,7 @@ namespace Mono.CSharp {
                                t = ec.ContainerType;
 
                        parent_constructor_group = Expression.MemberLookup (
-                               ec, t, null, t, ".ctor", 0, 
+                               ec, t, null, t, ".ctor", 
                                MemberTypes.Constructor,
                                BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly,
                                loc);
@@ -3939,7 +3939,7 @@ namespace Mono.CSharp {
                        if (ec.ContainerType.BaseType != null) {
                                Expression member_lookup = Expression.MemberLookup (
                                        ec, ec.ContainerType.BaseType, null, ec.ContainerType.BaseType,
-                                       "Finalize", 0, MemberTypes.Method, Expression.AllBindingFlags, Location);
+                                       "Finalize", MemberTypes.Method, Expression.AllBindingFlags, Location);
 
                                if (member_lookup != null){
                                        MethodGroupExpr parent_destructor = ((MethodGroupExpr) member_lookup);
index 0500c910b45630cf0e1d233264aaeef707771f44..9bdc1ed4b15564686261060325ca300064f23899 100755 (executable)
@@ -704,7 +704,7 @@ struct_declaration
                new_struct = new Struct (current_namespace, current_container, full_struct_name,
                                         (int) $2, (Attributes) $1, lexer.Location);
                current_container = new_struct;
-               RootContext.Tree.RecordDecl (full_struct_name, new_struct);
+               RootContext.Tree.RecordDecl (full_struct_name.GetName (true), new_struct);
                lexer.ConstraintsParsing = true;
          }
          opt_class_base
@@ -1257,7 +1257,8 @@ interface_declaration
                }
                current_interface = new_interface;
                current_container = new_interface;
-               RootContext.Tree.RecordDecl (full_interface_name, new_interface);
+               RootContext.Tree.RecordDecl (
+                       full_interface_name.GetName (true), new_interface);
                lexer.ConstraintsParsing = true;
          }
          opt_class_base
@@ -1909,8 +1910,9 @@ enum_declaration
                                  ev.identifier, loc);
                }
 
-               CheckDef (current_container.AddEnum (e), (string) full_name, enum_location);
-               RootContext.Tree.RecordDecl (full_name, e);
+               string name = full_name.GetName (false);
+               CheckDef (current_container.AddEnum (e), name, enum_location);
+               RootContext.Tree.RecordDecl (name, e);
 
          }
        ;
@@ -2993,7 +2995,7 @@ class_declaration
                new_class = new Class (current_namespace, current_container, name, (int) $2, 
                                       (Attributes) $1, lexer.Location);
                current_container = new_class;
-               RootContext.Tree.RecordDecl (name, new_class);
+               RootContext.Tree.RecordDecl (name.GetName (true), new_class);
 
                lexer.ConstraintsParsing = true;
          }
index cb59ac1a65771123b51e16bd634363dafb96833e..633c017adca31b26cd0969924864bf20ecddc30c 100755 (executable)
@@ -73,13 +73,15 @@ namespace Mono.CSharp {
                                return full_name;
                }
 
-               public string GetTypeName ()
+               public string GetTypeName (bool full)
                {
-                       string full_name;
+                       string suffix = "";
+                       if (full && (TypeArguments != null))
+                               suffix = "!" + TypeArguments.Count;
                        if (Left != null)
-                               return Left.GetFullName () + "." + Name;
+                               return Left.GetTypeName (full) + "." + Name + suffix;
                        else
-                               return Name;
+                               return Name + suffix;
                }
 
                public Expression GetTypeExpression (Location loc)
@@ -175,21 +177,31 @@ namespace Mono.CSharp {
 
                public static readonly MemberName Null = new MemberName ("");
 
-               public string GetMemberName ()
+               public string Basename {
+                       get {
+                               if (TypeParameters != null)
+                                       return Name + "!" + TypeParameters.Length;
+                               else
+                                       return Name;
+                       }
+               }
+
+               public string GetName (bool is_generic)
                {
-                       string full_name;
+                       string name = is_generic ? Basename : Name;
                        if (TypeName != null)
-                               return TypeName.GetFullName () + "." + Name;
+                               return TypeName.GetTypeName (is_generic) + "." + name;
                        else
-                               return Name;
+                               return name;
                }
 
-               public static explicit operator string (MemberName name)
-               {
-                       if (name.TypeName != null)
-                               return name.TypeName + "." + name.Name;
-                       else
-                               return name.Name;
+               public int CountTypeParameters {
+                       get {
+                               if (TypeParameters != null)
+                                       return 0;
+                               else
+                                       return TypeParameters.Length;
+                       }
                }
 
                protected string PrintTypeParams ()
@@ -256,7 +268,7 @@ namespace Mono.CSharp {
 
                public MemberCore (MemberName name, Attributes attrs, Location loc)
                {
-                       Name = (string) name;
+                       Name = name.GetName (!(this is GenericMethod) && !(this is Method));
                        MemberName = name;
                        Location = loc;
                        attributes = attrs;
@@ -380,7 +392,7 @@ namespace Mono.CSharp {
                public void RecordDecl ()
                {
                        if ((NamespaceEntry != null) && (parent == RootContext.Tree.Types))
-                               NamespaceEntry.DefineName (Basename, this);
+                               NamespaceEntry.DefineName (MemberName.Basename, this);
                }
 
                /// <summary>
@@ -650,7 +662,7 @@ namespace Mono.CSharp {
                                return null;
 
                        if (e is SimpleName){
-                               SimpleName s = new SimpleName (((SimpleName) e).Name, -1, loc);
+                               SimpleName s = new SimpleName (((SimpleName) e).Name, loc);
                                d = s.ResolveAsTypeTerminal (type_resolve_ec);
 
                                if ((d == null) || (d.Type == null)) {
@@ -998,7 +1010,7 @@ namespace Mono.CSharp {
                ///   during the tree resolution process and potentially define
                ///   recursively the type
                /// </remarks>
-               public Type FindType (Location loc, string name, int num_type_args)
+               public Type FindType (Location loc, string name)
                {
                        Type t;
                        bool error;
@@ -1020,9 +1032,7 @@ namespace Mono.CSharp {
                                        if (error)
                                                return null;
 
-                                       if ((t != null) &&
-                                           containing_ds.CheckAccessLevel (t) &&
-                                           TypeManager.CheckGeneric (t, num_type_args))
+                                       if ((t != null) && containing_ds.CheckAccessLevel (t))
                                                return t;
 
                                        current_type = current_type.BaseType;
@@ -1038,7 +1048,7 @@ namespace Mono.CSharp {
                                if (error)
                                        return null;
 
-                               if ((t != null) && TypeManager.CheckGeneric (t, num_type_args))
+                               if (t != null)
                                        return t;
                        }
                        
@@ -1049,7 +1059,7 @@ namespace Mono.CSharp {
                        if (error)
                                return null;
                        
-                       if ((t != null) && TypeManager.CheckGeneric (t, num_type_args))
+                       if (t != null)
                                return t;
                        
                        //
@@ -1063,7 +1073,7 @@ namespace Mono.CSharp {
                                if (error)
                                        return null;
 
-                               if ((t != null) && TypeManager.CheckGeneric (t, num_type_args))
+                               if (t != null)
                                        return t;
 
                                //
@@ -1075,8 +1085,7 @@ namespace Mono.CSharp {
                                        if (error)
                                                return null;
 
-                                       if ((match != null) &&
-                                           TypeManager.CheckGeneric (match, num_type_args)) {
+                                       if (match != null) {
                                                if (t != null){
                                                        if (CheckAccessLevel (match)) {
                                                                Error_AmbiguousTypeReference (loc, name, t.FullName, match.FullName);
@@ -1088,7 +1097,7 @@ namespace Mono.CSharp {
                                                t = match;
                                        }
                                }
-                               if ((t != null) && TypeManager.CheckGeneric (t, num_type_args))
+                               if (t != null)
                                        return t;
                        }
 
index ab5e4f4c34ca8f4e6bcde976206df821d8bf18ec..ad025d6ee4806c280f2ed9c774bacc147c6685ed 100755 (executable)
@@ -308,7 +308,7 @@ namespace Mono.CSharp {
 
                                if ((flags & ResolveFlags.SimpleName) == 0) {
                                        MemberLookupFailed (ec, null, ec.ContainerType, s.Name,
-                                                           0, ec.DeclSpace.Name, loc);
+                                                           ec.DeclSpace.Name, loc);
                                        return null;
                                }
 
@@ -395,7 +395,7 @@ namespace Mono.CSharp {
                                if (e is SimpleName){
                                        SimpleName s = (SimpleName) e;
                                        MemberLookupFailed (ec, null, ec.ContainerType, s.Name,
-                                                           0, ec.DeclSpace.Name, loc);
+                                                           ec.DeclSpace.Name, loc);
                                        return null;
                                }
 
@@ -542,7 +542,7 @@ namespace Mono.CSharp {
                public static Expression MemberLookup (EmitContext ec, Type queried_type, string name,
                                                       MemberTypes mt, BindingFlags bf, Location loc)
                {
-                       return MemberLookup (ec, ec.ContainerType, null, queried_type, name, 0, mt, bf, loc);
+                       return MemberLookup (ec, ec.ContainerType, null, queried_type, name, mt, bf, loc);
                }
 
                //
@@ -552,13 +552,11 @@ namespace Mono.CSharp {
 
                public static Expression MemberLookup (EmitContext ec, Type container_type,
                                                       Type qualifier_type, Type queried_type,
-                                                      string name, int num_type_arguments,
-                                                      MemberTypes mt, BindingFlags bf,
-                                                      Location loc)
+                                                      string name, MemberTypes mt,
+                                                      BindingFlags bf, Location loc)
                {
-                       MemberInfo [] mi = TypeManager.MemberLookup (container_type, qualifier_type,
-                                                                    queried_type, num_type_arguments,
-                                                                    mt, bf, name);
+                       MemberInfo [] mi = TypeManager.MemberLookup (
+                               container_type, qualifier_type,queried_type, mt, bf, name);
 
                        if (mi == null)
                                return null;
@@ -587,34 +585,25 @@ namespace Mono.CSharp {
                        BindingFlags.Static |
                        BindingFlags.Instance;
 
-               public static Expression MemberLookup (EmitContext ec, Type queried_type,
-                                                      string name, int num_type_arguments,
-                                                      Location loc)
-               {
-                       return MemberLookup (ec, ec.ContainerType, null, queried_type, name,
-                                            num_type_arguments, AllMemberTypes, AllBindingFlags,
-                                            loc);
-               }
-
                public static Expression MemberLookup (EmitContext ec, Type queried_type,
                                                       string name, Location loc)
                {
                        return MemberLookup (ec, ec.ContainerType, null, queried_type, name,
-                                            0, AllMemberTypes, AllBindingFlags, loc);
+                                            AllMemberTypes, AllBindingFlags, loc);
                }
 
                public static Expression MemberLookup (EmitContext ec, Type qualifier_type,
                                                       Type queried_type, string name, Location loc)
                {
                        return MemberLookup (ec, ec.ContainerType, qualifier_type, queried_type,
-                                            name, 0, AllMemberTypes, AllBindingFlags, loc);
+                                            name, AllMemberTypes, AllBindingFlags, loc);
                }
 
                public static Expression MethodLookup (EmitContext ec, Type queried_type,
                                                       string name, Location loc)
                {
                        return MemberLookup (ec, ec.ContainerType, null, queried_type, name,
-                                            0, MemberTypes.Method, AllBindingFlags, loc);
+                                            MemberTypes.Method, AllBindingFlags, loc);
                }
 
                /// <summary>
@@ -625,24 +614,23 @@ namespace Mono.CSharp {
                /// </summary>
                public static Expression MemberLookupFinal (EmitContext ec, Type qualifier_type,
                                                            Type queried_type, string name,
-                                                           int num_type_arguments, Location loc)
+                                                           Location loc)
                {
                        return MemberLookupFinal (ec, qualifier_type, queried_type, name,
-                                                 num_type_arguments, AllMemberTypes,
-                                                 AllBindingFlags, loc);
+                                                 AllMemberTypes, AllBindingFlags, loc);
                }
 
                public static Expression MemberLookupFinal (EmitContext ec, Type qualifier_type,
                                                            Type queried_type, string name,
-                                                           int num_type_arguments, MemberTypes mt,
-                                                           BindingFlags bf, Location loc)
+                                                           MemberTypes mt, BindingFlags bf,
+                                                           Location loc)
                {
                        Expression e;
 
                        int errors = Report.Errors;
 
                        e = MemberLookup (ec, ec.ContainerType, qualifier_type, queried_type,
-                                         name, num_type_arguments, mt, bf, loc);
+                                         name, mt, bf, loc);
 
                        if (e != null)
                                return e;
@@ -652,17 +640,16 @@ namespace Mono.CSharp {
                                return null;
 
                        MemberLookupFailed (ec, qualifier_type, queried_type, name,
-                                           num_type_arguments, null, loc);
+                                           null, loc);
                        return null;
                }
 
                public static void MemberLookupFailed (EmitContext ec, Type qualifier_type,
                                                       Type queried_type, string name,
-                                                      int num_type_arguments, string class_name,
-                                                      Location loc)
+                                                      string class_name, Location loc)
                {
                        MemberInfo[] mi = TypeManager.MemberLookup (queried_type, null, queried_type,
-                                                                   -1, AllMemberTypes, AllBindingFlags |
+                                                                   AllMemberTypes, AllBindingFlags |
                                                                    BindingFlags.NonPublic, name);
 
                        if (mi == null) {
@@ -677,7 +664,7 @@ namespace Mono.CSharp {
                        }
 
                        if (TypeManager.MemberLookup (queried_type, null, queried_type,
-                                                     0, AllMemberTypes, AllBindingFlags |
+                                                     AllMemberTypes, AllBindingFlags |
                                                      BindingFlags.NonPublic, name) == null) {
                                if ((mi.Length == 1) && (mi [0] is Type)) {
                                        Type t = (Type) mi [0];
@@ -701,7 +688,7 @@ namespace Mono.CSharp {
 
                                mi = TypeManager.MemberLookup (
                                        ec.ContainerType, ec.ContainerType, ec.ContainerType,
-                                       0, AllMemberTypes, AllBindingFlags, name);
+                                       AllMemberTypes, AllBindingFlags, name);
 
                                if (mi != null) {
                                        Report.Error (
@@ -1950,7 +1937,6 @@ namespace Mono.CSharp {
        /// </remarks>
        public class SimpleName : Expression {
                public string Name;
-               public int NumTypeArguments;
 
                //
                // If true, then we are a simple name, not composed with a ".
@@ -1971,14 +1957,6 @@ namespace Mono.CSharp {
                        is_base = true;
                }
 
-               public SimpleName (string name, int num_type_arguments, Location l)
-               {
-                       Name = name;
-                       NumTypeArguments = num_type_arguments;
-                       loc = l;
-                       is_base = true;
-               }
-
                public static void Error_ObjectRefRequired (EmitContext ec, Location l, string name)
                {
                        if (ec.IsFieldInitializer)
@@ -2049,7 +2027,7 @@ namespace Mono.CSharp {
 
                        if (ec.ResolvingTypeTree){
                                int errors = Report.Errors;
-                               Type dt = ds.FindType (loc, Name, NumTypeArguments);
+                               Type dt = ds.FindType (loc, Name);
                                
                                if (Report.Errors != errors)
                                        return null;
@@ -2060,7 +2038,7 @@ namespace Mono.CSharp {
                                if (alias_value != null){
                                        if (alias_value.IsType)
                                                return alias_value.Type;
-                                       if ((t = RootContext.LookupType (ds, alias_value.Name, true, NumTypeArguments, loc)) != null)
+                                       if ((t = RootContext.LookupType (ds, alias_value.Name, true, loc)) != null)
                                                return t;
                                }
                        }
@@ -2083,7 +2061,7 @@ namespace Mono.CSharp {
                        // or a namespace.
                        //
 
-                       if ((t = RootContext.LookupType (ds, Name, true, NumTypeArguments, loc)) != null)
+                       if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
                                return t;
                                
                        // No match, maybe our parent can compose us
@@ -2156,8 +2134,7 @@ namespace Mono.CSharp {
                                if (lookup_ds.TypeBuilder == null)
                                        break;
 
-                               e = MemberLookup (ec, lookup_ds.TypeBuilder,
-                                                 Name, NumTypeArguments, loc);
+                               e = MemberLookup (ec, lookup_ds.TypeBuilder, Name, loc);
                                if (e != null)
                                        break;
 
@@ -2165,8 +2142,7 @@ namespace Mono.CSharp {
                        } while (lookup_ds != null);
 
                        if (e == null && ec.ContainerType != null)
-                               e = MemberLookup (ec, ec.ContainerType,
-                                                 Name, NumTypeArguments, loc);
+                               e = MemberLookup (ec, ec.ContainerType, Name, loc);
 
                        if (e == null) {
                                //
@@ -3126,7 +3102,7 @@ namespace Mono.CSharp {
 
                        group = TypeManager.MemberLookup (
                                invocation_type, invocation_type, PropertyInfo.DeclaringType,
-                               0, MemberTypes.Method, flags, accessor_name + "_" + PropertyInfo.Name);
+                               MemberTypes.Method, flags, accessor_name + "_" + PropertyInfo.Name);
 
                        //
                        // The first method is the closest to us
index d87c0b33d2962e410fd98f40f8cddf515156ed1f..f6b64555babf5534809cbf0443f0dd0758ab11bf 100755 (executable)
@@ -5706,7 +5706,7 @@ namespace Mono.CSharp {
                                return this;
                        
                        Expression ml;
-                       ml = MemberLookupFinal (ec, null, type, ".ctor", 0,
+                       ml = MemberLookupFinal (ec, null, type, ".ctor",
                                                MemberTypes.Constructor,
                                                AllBindingFlags | BindingFlags.DeclaredOnly, loc);
 
@@ -6928,8 +6928,7 @@ namespace Mono.CSharp {
        ///   Implements the member access expression
        /// </summary>
        public class MemberAccess : Expression {
-               public readonly string Identifier;
-               public readonly int NumTypeArguments;
+               public string Identifier;
                protected Expression expr;
                
                public MemberAccess (Expression expr, string id, Location l)
@@ -6939,13 +6938,6 @@ namespace Mono.CSharp {
                        loc = l;
                }
 
-               protected MemberAccess (Expression expr, string id, int num_type_args,
-                                       Location l)
-                       : this (expr, id, l)
-               {
-                       NumTypeArguments = num_type_args;
-               }
-
                public Expression Expr {
                        get {
                                return expr;
@@ -7226,13 +7218,9 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       int real_num_type_args = NumTypeArguments +
-                               TypeManager.GetNumberOfTypeArguments (expr_type);
-                       
                        Expression member_lookup;
-                       member_lookup = MemberLookupFinal (ec, expr_type, expr_type,
-                                                          Identifier, real_num_type_args,
-                                                          loc);
+                       member_lookup = MemberLookupFinal (
+                               ec, expr_type, expr_type, Identifier, loc);
                        if (member_lookup == null)
                                return null;
 
@@ -7285,7 +7273,7 @@ namespace Mono.CSharp {
 
                                if (full_expr.Expr is SimpleName) {
                                        string full_name = String.Concat (((SimpleName) full_expr.Expr).Name, ".", fname);
-                                       Type fully_qualified = ec.DeclSpace.FindType (loc, full_name, 0);
+                                       Type fully_qualified = ec.DeclSpace.FindType (loc, full_name);
                                        if (fully_qualified != null)
                                                return new TypeExpression (fully_qualified, loc);
                                }
@@ -7314,13 +7302,9 @@ namespace Mono.CSharp {
                                return null;
                        }
 
-                       int real_num_type_args = NumTypeArguments +
-                               TypeManager.GetNumberOfTypeArguments (expr_type);
-                       
                        Expression member_lookup;
-                       member_lookup = MemberLookupFinal (ec, expr_type, expr_type,
-                                                          Identifier, real_num_type_args,
-                                                          loc);
+                       member_lookup = MemberLookupFinal (
+                               ec, expr_type, expr_type, Identifier, loc);
                        if (member_lookup == null)
                                return null;
 
@@ -7937,7 +7921,7 @@ namespace Mono.CSharp {
                        string p_name = TypeManager.IndexerPropertyName (lookup_type);
 
                        MemberInfo [] mi = TypeManager.MemberLookup (
-                               caller_type, caller_type, lookup_type, 0, MemberTypes.Property,
+                               caller_type, caller_type, lookup_type, MemberTypes.Property,
                                BindingFlags.Public | BindingFlags.Instance |
                                BindingFlags.DeclaredOnly, p_name);
 
@@ -8240,11 +8224,11 @@ namespace Mono.CSharp {
                        }
                        
                        member_lookup = MemberLookup (ec, ec.ContainerType, null, base_type,
-                                                     member, 0, AllMemberTypes,
-                                                     AllBindingFlags, loc);
+                                                     member, AllMemberTypes, AllBindingFlags,
+                                                     loc);
                        if (member_lookup == null) {
-                               MemberLookupFailed (ec, base_type, base_type, member,
-                                                   0, null, loc);
+                               MemberLookupFailed (
+                                       ec, base_type, base_type, member, null, loc);
                                return null;
                        }
 
index 4353a5bfc8654759483691936b92e32a2242d9dc..f999d09f915703b611fd1739770df833b232b33e 100644 (file)
@@ -429,7 +429,7 @@ namespace Mono.CSharp {
                public ConstructedType (string name, TypeArguments args, Location l)
                {
                        loc = l;
-                       this.name = name;
+                       this.name = name + "!" + args.Count;
                        this.args = args;
 
                        eclass = ExprClass.Type;
@@ -590,33 +590,12 @@ namespace Mono.CSharp {
                        Type t;
                        int num_args;
 
-                       SimpleName sn = new SimpleName (name, args.Count, loc);
+                       SimpleName sn = new SimpleName (name, loc);
                        TypeExpr resolved = sn.ResolveAsTypeTerminal (ec);
-                       if (resolved == null) {
-                               sn = new SimpleName (name, -1, loc);
-                               resolved = sn.ResolveAsTypeTerminal (ec);
-                               if ((resolved == null) || (resolved.Type == null)) {
-                                       Report.Error (246, loc,
-                                                     "The type or namespace name `{0}<...>' "+
-                                                     "could not be found", name);
-                                       return null;
-                               }
-
-                               t = resolved.Type;
-                               num_args = TypeManager.GetNumberOfTypeArguments (t);
-
-                               if (num_args == 0) {
-                                       Report.Error (308, loc,
-                                                     "The non-generic type `{0}' cannot " +
-                                                     "be used with type arguments.",
-                                                     TypeManager.CSharpName (t));
-                                       return null;
-                               }
-
-                               Report.Error (305, loc,
-                                             "Using the generic type `{0}' " +
-                                             "requires {1} type arguments",
-                                             TypeManager.GetFullName (t), num_args);
+                       if ((resolved == null) || (resolved.Type == null)) {
+                               Report.Error (246, loc,
+                                             "The type or namespace name `{0}<...>' "+
+                                             "could not be found", name);
                                return null;
                        }
 
@@ -684,7 +663,14 @@ namespace Mono.CSharp {
                        else
                                current = new TypeExpression (ec.ContainerType, loc);
 
-                       return new GenericMemberAccess (current, name, args, loc);
+                       string basename;
+                       int pos = name.LastIndexOf ('!');
+                       if (pos >= 0)
+                               basename = name.Substring (0, pos);
+                       else
+                               basename = name;
+
+                       return new GenericMemberAccess (current, basename, args, loc);
                }
 
                public override bool CheckAccessLevel (DeclSpace ds)
@@ -807,8 +793,9 @@ namespace Mono.CSharp {
                TypeArguments args;
                bool has_outer_params;
 
-               public GenericMemberAccess (Expression expr, string id, TypeArguments args, Location loc)
-                       : base (expr, id, args.Count, loc)
+               public GenericMemberAccess (Expression expr, string id, TypeArguments args,
+                                           Location loc)
+                       : base (expr, id, loc)
                {
                        this.args = args;
                }
@@ -838,23 +825,9 @@ namespace Mono.CSharp {
                        if (expr == null)
                                return null;
 
-                       TypeExpr texpr = expr as TypeExpr;
-                       if (texpr != null) {
-                               Type t = texpr.ResolveType (ec);
-                               if (t == null)
-                                       return null;
-
-                               ConstructedType ctype = new ConstructedType (t, args, loc);
-                               return ctype.DoResolve (ec);
-                       }
-
                        MethodGroupExpr mg = expr as MethodGroupExpr;
-                       if (mg == null) {
+                       if (mg == null)
                                return expr;
-                               Report.Error (-220, loc, "Member `{0}' has type arguments, but did " +
-                                             "not resolve as a method group.", Identifier);
-                               return null;
-                       }
 
                        if (args.Resolve (ec) == false)
                                return null;
@@ -891,8 +864,7 @@ namespace Mono.CSharp {
 
                public override Expression ResolveAsTypeStep (EmitContext ec)
                {
-                       if (!DoResolveBase (ec))
-                               return null;
+                       Identifier = Identifier + "!" + args.Count;
 
                        expr = base.ResolveAsTypeStep (ec);
                        if (expr == null)
index 138c318527b70bd4d7914182536509e7cf7c001f..6e3fbda610fe0c5dd336d6353706d118043e58f1 100755 (executable)
@@ -267,7 +267,7 @@ namespace Mono.CSharp {
                                // this will fail with `using A = Stack<int>'
                                //
                                
-                               string alias = Alias.GetTypeName ();
+                               string alias = Alias.GetTypeName (true);
                                while ((curr_ns != null) && (resolved == null)) {
                                        resolved = curr_ns.Lookup (
                                                null, alias, Alias.CountTypeArguments,
index b03b7761093d7dfbe8f3dc62b956bb002bf24975..17059c13658226243322f563b218435c6c6d33a9 100755 (executable)
@@ -53,10 +53,8 @@ namespace Mono.CSharp
 
                DoubleHash decl_ns_name = new DoubleHash ();
                
-               public void RecordDecl (MemberName member_name, DeclSpace ds)
+               public void RecordDecl (string name, DeclSpace ds)
                {
-                       string name = (string) member_name;
-
                        if (decls.Contains (name)){
                                Report.Error (
                                        101, ds.Location,
index a3fd439541e9648015a6597274b80ac8c1f23966..1db29d4f1e43430d7aaf22e3201eecfe5291e8e2 100755 (executable)
@@ -1375,8 +1375,7 @@ public class TypeManager {
        ///   to check base classes and interfaces anymore.
        /// </summary>
        private static MemberList MemberLookup_FindMembers (Type t, MemberTypes mt, BindingFlags bf,
-                                                           string name, int num_type_arguments,
-                                                           out bool used_cache)
+                                                           string name, out bool used_cache)
        {
                //
                // We have to take care of arrays specially, because GetType on
@@ -1527,36 +1526,6 @@ public class TypeManager {
                } else
                        return t.GetGenericArguments ();
        }
-
-       public static bool CheckGeneric (Type t, int num_type_arguments)
-       {
-               if (num_type_arguments < 0)
-                       return true;
-
-               DeclSpace tc = LookupDeclSpace (t);
-
-               if (tc != null) {
-                       if (!tc.IsGeneric)
-                               return num_type_arguments == 0;
-
-                       if (num_type_arguments == 0)
-                               return false;
-
-                       if (num_type_arguments != tc.CountTypeParameters)
-                               return false;
-               } else {
-                       if (!t.HasGenericArguments)
-                               return num_type_arguments == 0;
-
-                       if (num_type_arguments == 0)
-                               return false;
-
-                       if (num_type_arguments != t.GetGenericArguments ().Length)
-                               return false;
-               }
-
-               return true;
-       }
        
        //
        // Whether a type is unmanaged.  This is used by the unsafe code (25.2)
@@ -2630,7 +2599,6 @@ public class TypeManager {
        //
        static Type     closure_invocation_type;
        static Type     closure_qualifier_type;
-       static int      closure_num_type_arguments;
 
        //
        // The assembly that defines the type is that is calling us
@@ -2656,9 +2624,6 @@ public class TypeManager {
                if ((filter_criteria != null) && (m.Name != (string) filter_criteria))
                        return false;
 
-               if (m is Type)
-                       return TypeManager.CheckGeneric ((Type) m, closure_num_type_arguments);
-
                if (((closure_qualifier_type == null) || (closure_qualifier_type == closure_invocation_type)) &&
                    (closure_invocation_type != null) && IsEqual (m.DeclaringType, closure_invocation_type))
                        return true;
@@ -2806,15 +2771,13 @@ public class TypeManager {
        // that might return multiple matches.
        //
        public static MemberInfo [] MemberLookup (Type invocation_type, Type qualifier_type,
-                                                 Type queried_type, int num_type_arguments,
-                                                 MemberTypes mt, BindingFlags original_bf,
-                                                 string name)
+                                                 Type queried_type, MemberTypes mt,
+                                                 BindingFlags original_bf, string name)
        {
                Timer.StartTimer (TimerType.MemberLookup);
 
                MemberInfo[] retval = RealMemberLookup (invocation_type, qualifier_type,
-                                                       queried_type, num_type_arguments,
-                                                       mt, original_bf, name);
+                                                       queried_type, mt, original_bf, name);
 
                Timer.StopTimer (TimerType.MemberLookup);
 
@@ -2822,9 +2785,8 @@ public class TypeManager {
        }
 
        static MemberInfo [] RealMemberLookup (Type invocation_type, Type qualifier_type,
-                                              Type queried_type, int num_type_arguments,
-                                              MemberTypes mt, BindingFlags original_bf,
-                                              string name)
+                                              Type queried_type, MemberTypes mt,
+                                              BindingFlags original_bf, string name)
        {
                BindingFlags bf = original_bf;
                
@@ -2838,8 +2800,6 @@ public class TypeManager {
                closure_invocation_assembly = invocation_type != null ? invocation_type.Assembly : null;
                closure_qualifier_type = qualifier_type;
 
-               closure_num_type_arguments = num_type_arguments;
-
                //
                // If we are a nested class, we always have access to our container
                // type names
@@ -2883,8 +2843,8 @@ public class TypeManager {
 
                        Timer.StopTimer (TimerType.MemberLookup);
 
-                       list = MemberLookup_FindMembers (current_type, mt, bf, name,
-                                                        num_type_arguments, out used_cache);
+                       list = MemberLookup_FindMembers (
+                               current_type, mt, bf, name, out used_cache);
 
                        Timer.StartTimer (TimerType.MemberLookup);
 
@@ -2982,8 +2942,7 @@ public class TypeManager {
                foreach (TypeExpr itype in ifaces){
                        MemberInfo [] x;
 
-                       x = MemberLookup (null, null, itype.Type, num_type_arguments,
-                                         mt, bf, name);
+                       x = MemberLookup (null, null, itype.Type, mt, bf, name);
                        if (x != null)
                                return x;
                }