updated browser capabilities file
[mono.git] / mcs / gmcs / generic.cs
index 8463947696e8f68131f031d74a4fe09cb24bdf7e..b26083f895cd59c2f8715c0efa27bcd31f0e2ace 100644 (file)
@@ -245,6 +245,11 @@ namespace Mono.CSharp {
                        args.Add (type);
                }
 
+               public void Add (TypeArguments new_args)
+               {
+                       args.AddRange (new_args.args);
+               }
+
                public Type[] Arguments {
                        get {
                                return atypes;
@@ -327,9 +332,25 @@ namespace Mono.CSharp {
                        full_name = name + "<" + args.ToString () + ">";
                }
 
+               public ConstructedType (Type t, TypeParameter[] type_params, Location l)
+                       : this (t.Name, type_params, l)
+               {
+                       gt = t.GetGenericTypeDefinition ();
+               }
+
+               public ConstructedType (Type t, TypeArguments args, Location l)
+                       : this (t.Name, args, l)
+               {
+                       gt = t.GetGenericTypeDefinition ();
+               }
+
+               public TypeArguments TypeArguments {
+                       get { return args; }
+               }
+
                protected bool CheckConstraints (int index)
                {
-                       Type atype = args.Arguments [index];
+                       Type atype = atypes [index];
                        Type ptype = gen_params [index];
 
                        //// FIXME
@@ -402,7 +423,29 @@ namespace Mono.CSharp {
                        }
 
                        gen_params = gt.GetGenericArguments ();
-                       atypes = args.Arguments;
+
+                       DeclSpace decl = ec.DeclSpace, parent = null;
+                       while (decl != null) {
+                               if (TypeManager.IsNestedChildOf (gt, decl.TypeBuilder)) {
+                                       parent = decl;
+                                       break;
+                               }
+                               decl = decl.Parent;
+                       }
+
+                       if (parent != null) {
+                               TypeParameter[] pparams = parent.TypeParameters;
+
+                               atypes = new Type [args.Arguments.Length + pparams.Length];
+                               for (int i = 0; i < pparams.Length; i++) {
+                                       TypeParameter pparam = pparams [i];
+                                       if (pparam.Type == null)
+                                               throw new Exception ();
+                                       atypes [i] = pparam.Type;
+                               }
+                               args.Arguments.CopyTo (atypes, pparams.Length);
+                       } else
+                               atypes = args.Arguments;
 
                        if (atypes.Length != gen_params.Length) {
                                Report.Error (-217, loc, "Generic type `{0}' takes {1} " +
@@ -423,6 +466,11 @@ namespace Mono.CSharp {
                        return type;
                }
 
+               public Expression GetMemberAccess (TypeExpr current_type)
+               {
+                       return new GenericMemberAccess (current_type, name, args, loc);
+               }
+
                public override bool CheckAccessLevel (DeclSpace ds)
                {
                        return ds.CheckAccessLevel (gt);
@@ -561,6 +609,28 @@ namespace Mono.CSharp {
                        new_mg.InstanceExpression = mg.InstanceExpression;
                        return new_mg;
                }
+
+               public override Expression ResolveAsTypeStep (EmitContext ec)
+               {
+                       ConstructedType cexpr = expr as ConstructedType;
+                       if (cexpr == null)
+                               throw new Exception ();
+
+                       expr = base.ResolveAsTypeStep (ec);
+                       if (expr == null)
+                               return null;
+
+                       Type t = ((TypeExpr) expr).ResolveType (ec);
+                       if (t == null)
+                               return null;
+
+                       TypeArguments new_args = new TypeArguments ();
+                       new_args.Add (cexpr.TypeArguments);
+                       new_args.Add (args);
+
+                       ConstructedType ctype = new ConstructedType (t, new_args, loc);
+                       return ctype.ResolveAsTypeStep (ec);
+               }
        }
 
        public class DefaultValueExpression : Expression