* TypeDef.cs (GenericInfo):
[mono.git] / mcs / ilasm / codegen / TypeRef.cs
1 //
2 // Mono.ILASM.TypeRef
3 //
4 // Author(s):
5 //  Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Jackson Harper, All rights reserved
8 //
9
10 using System;
11 using System.Collections;
12
13 namespace Mono.ILASM {
14
15         /// <summary>
16         /// Reference to a type in the module being compiled.
17         /// </summary>
18         public class TypeRef : BaseClassRef {
19
20                 private Location location;
21                 public static readonly TypeRef Ellipsis = new TypeRef ("ELLIPSIS", false, null);
22                 public static readonly TypeRef Any = new TypeRef ("any", false, null);
23
24                 public TypeRef (string full_name, bool is_valuetype, Location location)
25                         : this (full_name, is_valuetype, location, null, null)
26                 {
27                 }
28
29                 public TypeRef (string full_name, bool is_valuetype, Location location, ArrayList conv_list, string sig_mod)
30                         : base (full_name, is_valuetype, conv_list, sig_mod)
31                 {
32                         this.location = location;
33                 }
34                 
35                 public override BaseClassRef Clone ()
36                 {
37                         return new TypeRef (full_name, is_valuetype, location, (ArrayList) ConversionList.Clone (), sig_mod);
38                 }
39
40                 protected override BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
41                         PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
42                 {
43                         if (SigMod == null | SigMod == "")
44                                 return new MethodRef (this, call_conv, ret_type, name, param, gen_param_count);
45                         else
46                                 return new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
47                 }
48
49                 protected override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
50                 {
51                          return new FieldRef (this, ret_type, name);
52                 }
53
54                 public override void Resolve (CodeGen code_gen)
55                 {
56                         if (is_resolved)
57                                 return;
58
59                         PEAPI.Type base_type;
60
61                         base_type = code_gen.TypeManager.GetPeapiType (full_name);
62
63                         if (base_type == null) {
64                                 code_gen.Report.Error ("Reference to undefined class '" +
65                                                        FullName + "'");
66                                 return;
67                         }
68                         type = Modify (code_gen, base_type);
69
70                         is_resolved = true;
71                 }
72
73                 public BaseClassRef AsClassRef (CodeGen code_gen)
74                 {
75                         return this;
76                 }
77
78                 public override string ToString ()
79                 {
80                         return FullName;
81                 }
82
83         }
84
85 }
86