2009-08-12 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / generic-mcs.cs
index dd80095e7c82d679dc7ba39879210e9a597b3ddb..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,6 +280,12 @@ namespace Mono.CSharp
                                return attributes;
                        }
                }
+
+               public Variance Variance {
+                       get {
+                               return variance;
+                       }
+               }
        }
 
        public class GenericTypeExpr : TypeExpr
@@ -230,12 +309,21 @@ namespace Mono.CSharp
                {
                        throw new NotImplementedException ();
                }
+
+               public TypeArguments TypeArguments {
+                       get { throw new NotImplementedException (); }
+               }
+
+               public bool VerifyVariantTypeParameters (IResolveContext rc)
+               {
+                       throw new NotImplementedException ();
+               }
        }
 
        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 ();
@@ -341,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 ();
@@ -350,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 ();
+               }
        }
 }