Contributed under the MIT/X11 license. This patch cleans up some
[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 GenericConstraints
31         {
32                 public bool HasValueTypeConstraint {
33                         get {
34                                 throw new NotImplementedException ();
35                         }
36                 }
37                         
38                 public abstract string TypeParameter {
39                         get;
40                 }
41
42                 public bool IsReferenceType { 
43                         get { throw new NotSupportedException (); }
44                 }
45                 
46                 public bool IsValueType { 
47                         get { throw new NotSupportedException (); }
48                 }               
49         }
50
51         public class Constraints : GenericConstraints
52         {
53                 public Constraints (string name, ArrayList constraints, Location loc)
54                 {
55                 }
56                 
57                 public Constraints Clone ()
58                 {
59                         throw new NotImplementedException ();
60                 }
61                 
62                 public Location Location {
63                         get { return Location.Null; } 
64                 }
65                 
66                 public override string TypeParameter {
67                         get { throw new NotImplementedException (); }
68                 }               
69
70                 public void VerifyClsCompliance ()
71                 {
72                 }
73         }
74
75         public class TypeParameter : MemberCore, IMemberContainer
76         {
77                 public TypeParameter (DeclSpace parent, DeclSpace decl, string name,
78                                       Constraints constraints, Attributes attrs, Variance variance, Location loc)
79                         : base (parent, new MemberName (name, loc), attrs)
80                 {
81                         throw new NotImplementedException ();
82                 }
83
84                 public static string GetSignatureForError (TypeParameter[] tp)
85                 {
86                         throw new NotImplementedException ();
87                 }
88
89                 //
90                 // MemberContainer
91                 //
92
93                 public override bool Define ()
94                 {
95                         return true;
96                 }
97
98                 public override void ApplyAttributeBuilder (Attribute a,
99                                                             CustomAttributeBuilder cb)
100                 {
101                         throw new NotImplementedException ();
102                 }
103
104                 public override AttributeTargets AttributeTargets {
105                         get { throw new NotImplementedException (); }
106                 }
107
108                 public override string[] ValidAttributeTargets {
109                         get {
110                                 return new string [] { "type parameter" };
111                         }
112                 }
113
114                 public Constraints Constraints {
115                         get {
116                                 return null;
117                         }
118                 }
119
120                 public override string DocCommentHeader {
121                         get { throw new NotImplementedException (); }
122                 }
123
124                 public bool Resolve (DeclSpace ds)
125                 {
126                         throw new NotImplementedException ();
127                 }
128
129                 public bool DefineType (IResolveContext ec)
130                 {
131                         throw new NotImplementedException ();
132                 }
133
134                 public bool DefineType (IResolveContext ec, MethodBuilder builder,
135                                         MethodInfo implementing, bool is_override)
136                 {
137                         throw new NotImplementedException ();
138                 }
139
140                 public bool CheckDependencies ()
141                 {
142                         throw new NotImplementedException ();
143                 }
144
145                 public bool UpdateConstraints (IResolveContext ec, Constraints new_constraints)
146                 {
147                         throw new NotImplementedException ();
148                 }
149
150                 //
151                 // IMemberContainer
152                 //
153
154                 public Type Type {
155                         get { throw new NotImplementedException (); }
156                 }
157
158                 string IMemberContainer.Name {
159                         get { throw new NotImplementedException (); }
160                 }
161
162                 public Variance Variance {
163                         get { throw new NotImplementedException (); }
164                 }
165
166                 MemberCache IMemberContainer.BaseCache {
167                         get { throw new NotImplementedException (); }
168                 }
169
170                 bool IMemberContainer.IsInterface {
171                         get { throw new NotImplementedException (); }
172                 }
173
174                 MemberList IMemberContainer.GetMembers (MemberTypes mt, BindingFlags bf)
175                 {
176                         throw new NotImplementedException ();
177                 }
178
179                 public bool IsSubclassOf (Type t)
180                 {
181                         throw new NotImplementedException ();
182                 }
183
184                 public MemberList FindMembers (MemberTypes mt, BindingFlags bf,
185                                                MemberFilter filter, object criteria)
186                 {
187                         throw new NotImplementedException ();
188                 }
189         }
190
191         public class TypeParameterExpr : TypeExpr
192         {
193                 public TypeParameterExpr (TypeParameter type_parameter, Location loc)
194                 {
195                         throw new NotImplementedException ();
196                 }
197
198                 protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
199                 {
200                         return null;
201                 }
202
203                 public TypeParameter TypeParameter {
204                         get {
205                                 throw new NotImplementedException ();
206                         }
207                 }
208         }
209
210         public class TypeParameterName : SimpleName
211         {
212                 Attributes attributes;
213                 Variance variance;
214
215                 public TypeParameterName (string name, Attributes attrs, Location loc)
216                         : this (name, attrs, Variance.None, loc)
217                 {
218                 }
219
220                 public TypeParameterName (string name, Attributes attrs, Variance variance, Location loc)
221                         : base (name, loc)
222                 {
223                         attributes = attrs;
224                         this.variance = variance;
225                 }
226
227                 public Attributes OptAttributes {
228                         get {
229                                 return attributes;
230                         }
231                 }
232
233                 public Variance Variance {
234                         get {
235                                 return variance;
236                         }
237                 }
238         }
239
240         public class GenericTypeExpr : TypeExpr
241         {
242                 public GenericTypeExpr (DeclSpace t, Location l)
243                 {
244                         throw new NotImplementedException ();
245                 }
246
247                 public GenericTypeExpr (Type t, TypeArguments args, Location l)
248                 {
249                         throw new NotImplementedException ();
250                 }
251
252                 protected override TypeExpr DoResolveAsTypeStep (IResolveContext ec)
253                 {
254                         throw new NotImplementedException ();
255                 }
256
257                 public bool CheckConstraints (IResolveContext ec)
258                 {
259                         throw new NotImplementedException ();
260                 }
261
262                 public bool VerifyVariantTypeParameters ()
263                 {
264                         throw new NotImplementedException ();
265                 }
266         }
267
268         public class GenericMethod : DeclSpace
269         {
270                 public GenericMethod (NamespaceEntry ns, DeclSpace parent, MemberName name,
271                                       Expression return_type, ParametersCompiled parameters)
272                         : base (ns, parent, name, null)
273                 {
274                         throw new NotImplementedException ();
275                 }
276
277                 public override TypeBuilder DefineType ()
278                 {
279                         throw new NotImplementedException ();
280                 }
281
282                 public override bool Define ()
283                 {
284                         throw new NotImplementedException ();
285                 }
286
287                 public bool DefineType (EmitContext ec, MethodBuilder mb,
288                                         MethodInfo implementing, bool is_override)
289                 {
290                         throw new NotImplementedException ();
291                 }
292
293                 public void EmitAttributes ()
294                 {
295                         throw new NotImplementedException ();
296                 }
297
298                 internal static void Error_ParameterNameCollision (Location loc, string name, string collisionWith)
299                 {
300                 }
301
302                 public override MemberCache MemberCache {
303                         get { throw new NotImplementedException (); }
304                 }
305
306                 public override AttributeTargets AttributeTargets {
307                         get {
308                                 return AttributeTargets.Method | AttributeTargets.ReturnValue;
309                         }
310                 }
311
312                 public override string DocCommentHeader {
313                         get { return "M:"; }
314                 }
315
316                 public new void VerifyClsCompliance ()
317                 {
318                         throw new NotImplementedException ();
319                 }
320         }
321
322         public class TypeArguments
323         {
324                 ArrayList args;
325                 
326                 public TypeArguments ()
327                 {
328                         args = new ArrayList ();
329                 }
330
331                 public TypeArguments (params Expression[] types)
332                 {
333                         args = new ArrayList (types);
334                 }
335                 
336                 public void Add (Expression type)
337                 {
338                 }
339
340                 public void Add (TypeArguments new_args)
341                 {
342                 }
343
344                 public bool Resolve (IResolveContext ec)
345                 {
346                         throw new NotImplementedException ();
347                 }
348
349                 public Type[] Arguments {
350                         get { throw new NotImplementedException (); }
351                 }
352
353                 public int Count {
354                         get {
355                                 return args.Count;
356                         }
357                 }
358
359                 public TypeParameterName[] GetDeclarations ()
360                 {
361                         throw new NotImplementedException ();
362                 }
363                 
364                 public string GetSignatureForError ()
365                 {
366                         throw new NotImplementedException ();
367                 }
368
369                 public TypeArguments Clone ()
370                 {
371                         throw new NotImplementedException ();
372                 }
373         }
374
375         public class TypeInferenceContext
376         {
377                 public void ExactInference (Type u, Type v)
378                 {
379                         throw new NotImplementedException ();
380                 }
381                 
382                 public Type InflateGenericArgument (Type t)
383                 {
384                         throw new NotImplementedException ();           
385                 }
386         }
387 }