2009-08-18 Marek Habersack <mhabersack@novell.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                 public static TypeParameter FindTypeParameter (TypeParameter[] all, string name)
133                 {
134                         throw new NotImplementedException ();
135                 }
136
137                 //
138                 // MemberContainer
139                 //
140
141                 public override bool Define ()
142                 {
143                         return true;
144                 }
145
146                 public void Define (Type t)
147                 {
148                 }
149
150                 public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb, PredefinedAttributes pa)
151                 {
152                         throw new NotImplementedException ();
153                 }
154
155                 public override AttributeTargets AttributeTargets {
156                         get { throw new NotImplementedException (); }
157                 }
158
159                 public override string[] ValidAttributeTargets {
160                         get {
161                                 return new string [] { "type parameter" };
162                         }
163                 }
164
165                 public Constraints Constraints {
166                         get {
167                                 return null;
168                         }
169                 }
170
171                 public override string DocCommentHeader {
172                         get { throw new NotImplementedException (); }
173                 }
174
175                 public bool Resolve (DeclSpace ds)
176                 {
177                         throw new NotImplementedException ();
178                 }
179
180                 public bool DefineType (IResolveContext ec)
181                 {
182                         throw new NotImplementedException ();
183                 }
184
185                 public bool DefineType (IResolveContext ec, MethodBuilder builder,
186                                         MethodInfo implementing, bool is_override)
187                 {
188                         throw new NotImplementedException ();
189                 }
190
191                 public bool CheckDependencies ()
192                 {
193                         throw new NotImplementedException ();
194                 }
195
196                 public bool UpdateConstraints (IResolveContext ec, Constraints new_constraints)
197                 {
198                         throw new NotImplementedException ();
199                 }
200
201                 //
202                 // IMemberContainer
203                 //
204
205                 public Type Type {
206                         get { throw new NotImplementedException (); }
207                 }
208
209                 string IMemberContainer.Name {
210                         get { throw new NotImplementedException (); }
211                 }
212
213                 public Variance Variance {
214                         get { throw new NotImplementedException (); }
215                 }
216
217                 MemberCache IMemberContainer.BaseCache {
218                         get { throw new NotImplementedException (); }
219                 }
220
221                 bool IMemberContainer.IsInterface {
222                         get { throw new NotImplementedException (); }
223                 }
224
225                 MemberList IMemberContainer.GetMembers (MemberTypes mt, BindingFlags bf)
226                 {
227                         throw new NotImplementedException ();
228                 }
229
230                 public bool IsSubclassOf (Type t)
231                 {
232                         throw new NotImplementedException ();
233                 }
234
235                 public MemberList FindMembers (MemberTypes mt, BindingFlags bf,
236                                                MemberFilter filter, object criteria)
237                 {
238                         throw new NotImplementedException ();
239                 }
240
241                 public void SetConstraints (GenericTypeParameterBuilder type)
242                 {
243                         throw new NotImplementedException ();
244                 }
245         }
246
247         public class TypeParameterExpr : TypeExpr
248         {
249                 public TypeParameterExpr (TypeParameter type_parameter, Location loc)
250                 {
251                         throw new NotImplementedException ();
252                 }
253
254                 protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
255                 {
256                         return null;
257                 }
258
259                 public TypeParameter TypeParameter {
260                         get {
261                                 throw new NotImplementedException ();
262                         }
263                 }
264         }
265
266         public class TypeParameterName : SimpleName
267         {
268                 Attributes attributes;
269                 Variance variance;
270
271                 public TypeParameterName (string name, Attributes attrs, Location loc)
272                         : this (name, attrs, Variance.None, loc)
273                 {
274                 }
275
276                 public TypeParameterName (string name, Attributes attrs, Variance variance, Location loc)
277                         : base (name, loc)
278                 {
279                         attributes = attrs;
280                         this.variance = variance;
281                 }
282
283                 public Attributes OptAttributes {
284                         get {
285                                 return attributes;
286                         }
287                 }
288
289                 public Variance Variance {
290                         get {
291                                 return variance;
292                         }
293                 }
294         }
295
296         public class GenericTypeExpr : TypeExpr
297         {
298                 public GenericTypeExpr (DeclSpace t, Location l)
299                 {
300                         throw new NotImplementedException ();
301                 }
302
303                 public GenericTypeExpr (Type t, TypeArguments args, Location l)
304                 {
305                         throw new NotImplementedException ();
306                 }
307
308                 protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
309                 {
310                         throw new NotImplementedException ();
311                 }
312
313                 public bool CheckConstraints (IResolveContext ec)
314                 {
315                         throw new NotImplementedException ();
316                 }
317
318                 public TypeArguments TypeArguments {
319                         get { throw new NotImplementedException (); }
320                 }
321
322                 public bool VerifyVariantTypeParameters (IResolveContext rc)
323                 {
324                         throw new NotImplementedException ();
325                 }
326         }
327
328         public class GenericMethod : DeclSpace
329         {
330                 public GenericMethod (NamespaceEntry ns, DeclSpace parent, MemberName name,
331                                       Expression return_type, ParametersCompiled parameters)
332                         : base (ns, parent, name, null)
333                 {
334                         throw new NotImplementedException ();
335                 }
336
337                 public override TypeBuilder DefineType ()
338                 {
339                         throw new NotImplementedException ();
340                 }
341
342                 public override bool Define ()
343                 {
344                         throw new NotImplementedException ();
345                 }
346
347                 public bool DefineType (EmitContext ec, MethodBuilder mb,
348                                         MethodInfo implementing, bool is_override)
349                 {
350                         throw new NotImplementedException ();
351                 }
352
353                 public void EmitAttributes ()
354                 {
355                         throw new NotImplementedException ();
356                 }
357
358                 internal static void Error_ParameterNameCollision (Location loc, string name, string collisionWith)
359                 {
360                 }
361
362                 public override MemberCache MemberCache {
363                         get { throw new NotImplementedException (); }
364                 }
365
366                 public override AttributeTargets AttributeTargets {
367                         get {
368                                 return AttributeTargets.Method | AttributeTargets.ReturnValue;
369                         }
370                 }
371
372                 public override string DocCommentHeader {
373                         get { return "M:"; }
374                 }
375
376                 public new void VerifyClsCompliance ()
377                 {
378                         throw new NotImplementedException ();
379                 }
380         }
381
382         public class TypeArguments
383         {
384                 ArrayList args;
385                 
386                 public TypeArguments ()
387                 {
388                         args = new ArrayList ();
389                 }
390
391                 public TypeArguments (params Expression[] types)
392                 {
393                         args = new ArrayList (types);
394                 }
395                 
396                 public void Add (Expression type)
397                 {
398                 }
399
400                 public void Add (TypeArguments new_args)
401                 {
402                 }
403
404                 public bool Resolve (IResolveContext ec)
405                 {
406                         throw new NotImplementedException ();
407                 }
408
409                 public Type[] Arguments {
410                         get { throw new NotImplementedException (); }
411                 }
412
413                 public int Count {
414                         get {
415                                 return args.Count;
416                         }
417                 }
418
419                 public TypeParameterName[] GetDeclarations ()
420                 {
421                         throw new NotImplementedException ();
422                 }
423                 
424                 public string GetSignatureForError ()
425                 {
426                         throw new NotImplementedException ();
427                 }
428
429                 public TypeArguments Clone ()
430                 {
431                         throw new NotImplementedException ();
432                 }
433         }
434
435         public class TypeInferenceContext
436         {
437                 public Type[] InferredTypeArguments;
438                 
439                 public void AddCommonTypeBound (Type type)
440                 {
441                         throw new NotImplementedException ();
442                 }
443                 
444                 public void ExactInference (Type u, Type v)
445                 {
446                         throw new NotImplementedException ();
447                 }
448                 
449                 public Type InflateGenericArgument (Type t)
450                 {
451                         throw new NotImplementedException ();           
452                 }
453                 
454                 public bool FixAllTypes ()
455                 {
456                         return false;
457                 }
458         }
459         
460         partial class TypeManager
461         {
462                 public static Variance CheckTypeVariance (Type type, Variance v, MemberCore mc)
463                 {
464                         return v;
465                 }
466                 
467                 public static bool IsVariantOf (Type a, Type b)
468                 {
469                         return false;
470                 }
471                 
472                 public static TypeContainer LookupGenericTypeContainer (Type t)
473                 {
474                         throw new NotImplementedException ();
475                 }
476         }
477 }