args.Add (type);
}
+ public void Add (TypeArguments new_args)
+ {
+ args.AddRange (new_args.args);
+ }
+
public Type[] Arguments {
get {
return atypes;
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
}
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} " +
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);
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