2009-08-12 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / generic-mcs.cs
index 941e9dfd5815527b048b15c2ca944ffebfdc36fd..39227ebfd5c35f5ca82d1dd132f0458703cc6f31 100644 (file)
@@ -13,19 +13,53 @@ using System.Collections;
 
 namespace Mono.CSharp
 {
+       public enum Variance
+       {
+               None,
+               Covariant,
+               Contravariant
+       }
+
        public enum SpecialConstraint
        {
                Constructor,
                ReferenceType,
                ValueType
        }
+
+       public abstract class GenericTypeParameterBuilder : Type
+       {
+       }
+
+       public class InternalsVisibleToAttribute
+       {
+               public string AssemblyName;
+       }
+
+       class ConstraintChecker
+       {
+               public static bool CheckConstraints (EmitContext ec, MethodBase a, MethodBase b, Location loc)
+               {
+                       throw new NotSupportedException ();
+               }
+       }
        
        public abstract class GenericConstraints
        {
+               public bool HasConstructorConstraint {
+                       get { throw new NotImplementedException (); }
+               }
+
                public bool HasValueTypeConstraint {
-                       get {
-                               throw new NotImplementedException ();
-                       }
+                       get { throw new NotImplementedException (); }
+               }
+
+               public bool HasClassConstraint {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public bool HasReferenceTypeConstraint {
+                       get { throw new NotImplementedException (); }
                }
                        
                public abstract string TypeParameter {
@@ -35,6 +69,22 @@ namespace Mono.CSharp
                public bool IsReferenceType { 
                        get { throw new NotSupportedException (); }
                }
+               
+               public bool IsValueType { 
+                       get { throw new NotSupportedException (); }
+               }
+
+               public Type[] InterfaceConstraints {
+                       get { throw new NotSupportedException (); }
+               }
+
+               public Type ClassConstraint {
+                       get { throw new NotSupportedException (); }
+               }
+
+               public Type EffectiveBaseClass {
+                       get { throw new NotSupportedException (); }
+               }
        }
 
        public class Constraints : GenericConstraints
@@ -64,7 +114,7 @@ namespace Mono.CSharp
        public class TypeParameter : MemberCore, IMemberContainer
        {
                public TypeParameter (DeclSpace parent, DeclSpace decl, string name,
-                                     Constraints constraints, Attributes attrs, Location loc)
+                                     Constraints constraints, Attributes attrs, Variance variance, Location loc)
                        : base (parent, new MemberName (name, loc), attrs)
                {
                        throw new NotImplementedException ();
@@ -74,6 +124,10 @@ namespace Mono.CSharp
                {
                        throw new NotImplementedException ();
                }
+               
+               public void ErrorInvalidVariance (MemberCore mc, Variance v)
+               {
+               }
 
                //
                // MemberContainer
@@ -84,8 +138,11 @@ namespace Mono.CSharp
                        return true;
                }
 
-               public override void ApplyAttributeBuilder (Attribute a,
-                                                           CustomAttributeBuilder cb)
+               public void Define (Type t)
+               {
+               }
+
+               public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
                {
                        throw new NotImplementedException ();
                }
@@ -148,6 +205,10 @@ namespace Mono.CSharp
                        get { throw new NotImplementedException (); }
                }
 
+               public Variance Variance {
+                       get { throw new NotImplementedException (); }
+               }
+
                MemberCache IMemberContainer.BaseCache {
                        get { throw new NotImplementedException (); }
                }
@@ -171,6 +232,11 @@ namespace Mono.CSharp
                {
                        throw new NotImplementedException ();
                }
+
+               public void SetConstraints (GenericTypeParameterBuilder type)
+               {
+                       throw new NotImplementedException ();
+               }
        }
 
        public class TypeParameterExpr : TypeExpr
@@ -195,11 +261,18 @@ namespace Mono.CSharp
        public class TypeParameterName : SimpleName
        {
                Attributes attributes;
+               Variance variance;
 
                public TypeParameterName (string name, Attributes attrs, Location loc)
+                       : this (name, attrs, Variance.None, loc)
+               {
+               }
+
+               public TypeParameterName (string name, Attributes attrs, Variance variance, Location loc)
                        : base (name, loc)
                {
                        attributes = attrs;
+                       this.variance = variance;
                }
 
                public Attributes OptAttributes {
@@ -207,31 +280,41 @@ namespace Mono.CSharp
                                return attributes;
                        }
                }
+
+               public Variance Variance {
+                       get {
+                               return variance;
+                       }
+               }
        }
 
-       public class ConstructedType : TypeExpr
+       public class GenericTypeExpr : TypeExpr
        {
-               public ConstructedType (FullNamedExpression fname, TypeArguments args, Location l)
+               public GenericTypeExpr (DeclSpace t, Location l)
                {
                        throw new NotImplementedException ();
                }
 
-               public ConstructedType (Type t, TypeParameter[] type_params, Location l)
+               public GenericTypeExpr (Type t, TypeArguments args, Location l)
                {
                        throw new NotImplementedException ();
                }
 
-               public ConstructedType (Type t, TypeArguments args, Location l)
+               protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
                {
                        throw new NotImplementedException ();
                }
 
-               protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
+               public bool CheckConstraints (IResolveContext ec)
                {
                        throw new NotImplementedException ();
                }
 
-               public bool CheckConstraints (IResolveContext ec)
+               public TypeArguments TypeArguments {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public bool VerifyVariantTypeParameters (IResolveContext rc)
                {
                        throw new NotImplementedException ();
                }
@@ -240,7 +323,7 @@ namespace Mono.CSharp
        public class GenericMethod : DeclSpace
        {
                public GenericMethod (NamespaceEntry ns, DeclSpace parent, MemberName name,
-                                     Expression return_type, Parameters parameters)
+                                     Expression return_type, ParametersCompiled parameters)
                        : base (ns, parent, name, null)
                {
                        throw new NotImplementedException ();
@@ -267,11 +350,6 @@ namespace Mono.CSharp
                        throw new NotImplementedException ();
                }
 
-               public override bool DefineMembers ()
-               {
-                       throw new NotImplementedException ();
-               }
-               
                internal static void Error_ParameterNameCollision (Location loc, string name, string collisionWith)
                {
                }
@@ -298,31 +376,18 @@ namespace Mono.CSharp
 
        public class TypeArguments
        {
-               public readonly Location Location;
                ArrayList args;
-               //Type[] atypes;
-               int dimension;
-               //bool has_type_args;
-               //bool created;
                
-               public TypeArguments (Location loc)
+               public TypeArguments ()
                {
                        args = new ArrayList ();
-                       this.Location = loc;
                }
 
-               public TypeArguments (Location loc, params Expression[] types)
+               public TypeArguments (params Expression[] types)
                {
-                       this.Location = loc;
-                       this.args = new ArrayList (types);
+                       args = new ArrayList (types);
                }
                
-               public TypeArguments (int dimension, Location loc)
-               {
-                       this.dimension = dimension;
-                       this.Location = loc;
-               }
-
                public void Add (Expression type)
                {
                }
@@ -342,17 +407,10 @@ namespace Mono.CSharp
 
                public int Count {
                        get {
-                               if (dimension > 0)
-                                       return dimension;
-                               else
-                                       return args.Count;
+                               return args.Count;
                        }
                }
 
-               public bool IsUnbound {
-                       get { throw new NotImplementedException (); }
-               }
-
                public TypeParameterName[] GetDeclarations ()
                {
                        throw new NotImplementedException ();
@@ -371,6 +429,13 @@ namespace Mono.CSharp
 
        public class TypeInferenceContext
        {
+               public Type[] InferredTypeArguments;
+               
+               public void AddCommonTypeBound (Type type)
+               {
+                       throw new NotImplementedException ();
+               }
+               
                public void ExactInference (Type u, Type v)
                {
                        throw new NotImplementedException ();
@@ -380,5 +445,28 @@ namespace Mono.CSharp
                {
                        throw new NotImplementedException ();           
                }
+               
+               public bool FixAllTypes ()
+               {
+                       return false;
+               }
+       }
+       
+       partial class TypeManager
+       {
+               public static Variance CheckTypeVariance (Type type, Variance v, MemberCore mc)
+               {
+                       return v;
+               }
+               
+               public static bool IsVariantOf (Type a, Type b)
+               {
+                       return false;
+               }
+               
+               public static TypeContainer LookupGenericTypeContainer (Type t)
+               {
+                       throw new NotImplementedException ();
+               }
        }
 }