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