2009-06-29 Marek Safar <marek.safar@gmail.com>
[mono.git] / mcs / mcs / generic-mcs.cs
1 //
2 // generic.cs: Support classes for generics to reduce differences from GMCS
3 //
4 // Author:
5 //   Raja R Harinath <rharinath@novell.com>
6 //
7 // Copyright 2006 Novell, Inc.
8 //
9 using System;
10 using System.Reflection;
11 using System.Reflection.Emit;
12 using System.Collections;
13
14 namespace Mono.CSharp
15 {
16         public enum Variance
17         {
18                 None,
19                 Covariant,
20                 Contravariant
21         }
22
23         public enum SpecialConstraint
24         {
25                 Constructor,
26                 ReferenceType,
27                 ValueType
28         }
29
30         public abstract class GenericTypeParameterBuilder : Type
31         {
32         }
33
34         public class InternalsVisibleToAttribute
35         {
36                 public string AssemblyName;
37         }
38
39         class ConstraintChecker
40         {
41                 public static bool CheckConstraints (EmitContext ec, MethodBase a, MethodBase b, Location loc)
42                 {
43                         throw new NotSupportedException ();
44                 }
45         }
46         
47         public abstract class GenericConstraints
48         {
49                 public bool HasConstructorConstraint {
50                         get { throw new NotImplementedException (); }
51                 }
52
53                 public bool HasValueTypeConstraint {
54                         get { throw new NotImplementedException (); }
55                 }
56
57                 public bool HasClassConstraint {
58                         get { throw new NotImplementedException (); }
59                 }
60
61                 public bool HasReferenceTypeConstraint {
62                         get { throw new NotImplementedException (); }
63                 }
64                         
65                 public abstract string TypeParameter {
66                         get;
67                 }
68
69                 public bool IsReferenceType { 
70                         get { throw new NotSupportedException (); }
71                 }
72                 
73                 public bool IsValueType { 
74                         get { throw new NotSupportedException (); }
75                 }
76
77                 public Type[] InterfaceConstraints {
78                         get { throw new NotSupportedException (); }
79                 }
80
81                 public Type ClassConstraint {
82                         get { throw new NotSupportedException (); }
83                 }
84
85                 public Type EffectiveBaseClass {
86                         get { throw new NotSupportedException (); }
87                 }
88         }
89
90         public class Constraints : GenericConstraints
91         {
92                 public Constraints (string name, ArrayList constraints, Location loc)
93                 {
94                 }
95                 
96                 public Constraints Clone ()
97                 {
98                         throw new NotImplementedException ();
99                 }
100                 
101                 public Location Location {
102                         get { return Location.Null; } 
103                 }
104                 
105                 public override string TypeParameter {
106                         get { throw new NotImplementedException (); }
107                 }               
108
109                 public void VerifyClsCompliance ()
110                 {
111                 }
112         }
113
114         public class TypeParameter : MemberCore, IMemberContainer
115         {
116                 public TypeParameter (DeclSpace parent, DeclSpace decl, string name,
117                                       Constraints constraints, Attributes attrs, Variance variance, Location loc)
118                         : base (parent, new MemberName (name, loc), attrs)
119                 {
120                         throw new NotImplementedException ();
121                 }
122
123                 public static string GetSignatureForError (TypeParameter[] tp)
124                 {
125                         throw new NotImplementedException ();
126                 }
127                 
128                 public void ErrorInvalidVariance (MemberCore mc, Variance v)
129                 {
130                 }
131
132                 //
133                 // MemberContainer
134                 //
135
136                 public override bool Define ()
137                 {
138                         return true;
139                 }
140
141                 public void Define (Type t)
142                 {
143                 }
144
145                 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
146                 {
147                         throw new NotImplementedException ();
148                 }
149
150                 public override AttributeTargets AttributeTargets {
151                         get { throw new NotImplementedException (); }
152                 }
153
154                 public override string[] ValidAttributeTargets {
155                         get {
156                                 return new string [] { "type parameter" };
157                         }
158                 }
159
160                 public Constraints Constraints {
161                         get {
162                                 return null;
163                         }
164                 }
165
166                 public override string DocCommentHeader {
167                         get { throw new NotImplementedException (); }
168                 }
169
170                 public bool Resolve (DeclSpace ds)
171                 {
172                         throw new NotImplementedException ();
173                 }
174
175                 public bool DefineType (IResolveContext ec)
176                 {
177                         throw new NotImplementedException ();
178                 }
179
180                 public bool DefineType (IResolveContext ec, MethodBuilder builder,
181                                         MethodInfo implementing, bool is_override)
182                 {
183                         throw new NotImplementedException ();
184                 }
185
186                 public bool CheckDependencies ()
187                 {
188                         throw new NotImplementedException ();
189                 }
190
191                 public bool UpdateConstraints (IResolveContext ec, Constraints new_constraints)
192                 {
193                         throw new NotImplementedException ();
194                 }
195
196                 //
197                 // IMemberContainer
198                 //
199
200                 public Type Type {
201                         get { throw new NotImplementedException (); }
202                 }
203
204                 string IMemberContainer.Name {
205                         get { throw new NotImplementedException (); }
206                 }
207
208                 public Variance Variance {
209                         get { throw new NotImplementedException (); }
210                 }
211
212                 MemberCache IMemberContainer.BaseCache {
213                         get { throw new NotImplementedException (); }
214                 }
215
216                 bool IMemberContainer.IsInterface {
217                         get { throw new NotImplementedException (); }
218                 }
219
220                 MemberList IMemberContainer.GetMembers (MemberTypes mt, BindingFlags bf)
221                 {
222                         throw new NotImplementedException ();
223                 }
224
225                 public bool IsSubclassOf (Type t)
226                 {
227                         throw new NotImplementedException ();
228                 }
229
230                 public MemberList FindMembers (MemberTypes mt, BindingFlags bf,
231                                                MemberFilter filter, object criteria)
232                 {
233                         throw new NotImplementedException ();
234                 }
235
236                 public void SetConstraints (GenericTypeParameterBuilder type)
237                 {
238                         throw new NotImplementedException ();
239                 }
240         }
241
242         public class TypeParameterExpr : TypeExpr
243         {
244                 public TypeParameterExpr (TypeParameter type_parameter, Location loc)
245                 {
246                         throw new NotImplementedException ();
247                 }
248
249                 protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
250                 {
251                         return null;
252                 }
253
254                 public TypeParameter TypeParameter {
255                         get {
256                                 throw new NotImplementedException ();
257                         }
258                 }
259         }
260
261         public class TypeParameterName : SimpleName
262         {
263                 Attributes attributes;
264                 Variance variance;
265
266                 public TypeParameterName (string name, Attributes attrs, Location loc)
267                         : this (name, attrs, Variance.None, loc)
268                 {
269                 }
270
271                 public TypeParameterName (string name, Attributes attrs, Variance variance, Location loc)
272                         : base (name, loc)
273                 {
274                         attributes = attrs;
275                         this.variance = variance;
276                 }
277
278                 public Attributes OptAttributes {
279                         get {
280                                 return attributes;
281                         }
282                 }
283
284                 public Variance Variance {
285                         get {
286                                 return variance;
287                         }
288                 }
289         }
290
291         public class GenericTypeExpr : TypeExpr
292         {
293                 public GenericTypeExpr (DeclSpace t, Location l)
294                 {
295                         throw new NotImplementedException ();
296                 }
297
298                 public GenericTypeExpr (Type t, TypeArguments args, Location l)
299                 {
300                         throw new NotImplementedException ();
301                 }
302
303                 protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
304                 {
305                         throw new NotImplementedException ();
306                 }
307
308                 public bool CheckConstraints (IResolveContext ec)
309                 {
310                         throw new NotImplementedException ();
311                 }
312
313                 public TypeArguments TypeArguments {
314                         get { throw new NotImplementedException (); }
315                 }
316
317                 public bool VerifyVariantTypeParameters (IResolveContext rc)
318                 {
319                         throw new NotImplementedException ();
320                 }
321         }
322
323         public class GenericMethod : DeclSpace
324         {
325                 public GenericMethod (NamespaceEntry ns, DeclSpace parent, MemberName name,
326                                       Expression return_type, ParametersCompiled parameters)
327                         : base (ns, parent, name, null)
328                 {
329                         throw new NotImplementedException ();
330                 }
331
332                 public override TypeBuilder DefineType ()
333                 {
334                         throw new NotImplementedException ();
335                 }
336
337                 public override bool Define ()
338                 {
339                         throw new NotImplementedException ();
340                 }
341
342                 public bool DefineType (EmitContext ec, MethodBuilder mb,
343                                         MethodInfo implementing, bool is_override)
344                 {
345                         throw new NotImplementedException ();
346                 }
347
348                 public void EmitAttributes ()
349                 {
350                         throw new NotImplementedException ();
351                 }
352
353                 internal static void Error_ParameterNameCollision (Location loc, string name, string collisionWith)
354                 {
355                 }
356
357                 public override MemberCache MemberCache {
358                         get { throw new NotImplementedException (); }
359                 }
360
361                 public override AttributeTargets AttributeTargets {
362                         get {
363                                 return AttributeTargets.Method | AttributeTargets.ReturnValue;
364                         }
365                 }
366
367                 public override string DocCommentHeader {
368                         get { return "M:"; }
369                 }
370
371                 public new void VerifyClsCompliance ()
372                 {
373                         throw new NotImplementedException ();
374                 }
375         }
376
377         public class TypeArguments
378         {
379                 ArrayList args;
380                 
381                 public TypeArguments ()
382                 {
383                         args = new ArrayList ();
384                 }
385
386                 public TypeArguments (params Expression[] types)
387                 {
388                         args = new ArrayList (types);
389                 }
390                 
391                 public void Add (Expression type)
392                 {
393                 }
394
395                 public void Add (TypeArguments new_args)
396                 {
397                 }
398
399                 public bool Resolve (IResolveContext ec)
400                 {
401                         throw new NotImplementedException ();
402                 }
403
404                 public Type[] Arguments {
405                         get { throw new NotImplementedException (); }
406                 }
407
408                 public int Count {
409                         get {
410                                 return args.Count;
411                         }
412                 }
413
414                 public TypeParameterName[] GetDeclarations ()
415                 {
416                         throw new NotImplementedException ();
417                 }
418                 
419                 public string GetSignatureForError ()
420                 {
421                         throw new NotImplementedException ();
422                 }
423
424                 public TypeArguments Clone ()
425                 {
426                         throw new NotImplementedException ();
427                 }
428         }
429
430         public class TypeInferenceContext
431         {
432                 public void ExactInference (Type u, Type v)
433                 {
434                         throw new NotImplementedException ();
435                 }
436                 
437                 public Type InflateGenericArgument (Type t)
438                 {
439                         throw new NotImplementedException ();           
440                 }
441         }
442         
443         partial class TypeManager
444         {
445                 public static Variance CheckTypeVariance (Type type, Variance v, MemberCore mc)
446                 {
447                         return v;
448                 }
449                 
450                 public static bool IsVariantOf (Type a, Type b)
451                 {
452                         return false;
453                 }
454         }
455 }