* CodeGen.cs: Fix tabbing
[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 : ModifiableType, IClassRef {
19
20                 private enum ConversionMethod {
21                         MakeArray,
22                         MakeBoundArray,
23                         MakeManagedPointer,
24                         MakeUnmanagedPointer,
25                         MakeCustomModified
26                 }
27
28                 private Location location;
29                 private string full_name;
30                 private string sig_mod;
31                 private PEAPI.Type type;
32                 private bool is_valuetype;
33
34                 private bool is_resolved;
35
36                 public static readonly TypeRef Ellipsis = new TypeRef ("ELLIPSIS", false, null);
37                 public static readonly TypeRef Any = new TypeRef ("any", false, null);
38
39                 public TypeRef (string full_name, bool is_valuetype, Location location)
40                 {
41                         this.full_name = full_name;
42                         this.location = location;
43                         this.is_valuetype = is_valuetype;
44                         sig_mod = String.Empty;
45                         is_resolved = false;
46                 }
47
48                 public string FullName {
49                         get { return full_name + sig_mod; }
50                 }
51
52                 public override string SigMod {
53                         get { return sig_mod; }
54                         set { sig_mod = value; }
55                 }
56
57                 public PEAPI.Type PeapiType {
58                         get { return type; }
59                 }
60
61                 public PEAPI.Class PeapiClass {
62                         get { return type as PEAPI.Class; }
63                 }
64
65                 public bool IsResolved {
66                         get { return is_resolved; }
67                 }
68
69                 public void MakeValueClass ()
70                 {
71                         is_valuetype = true;
72                 }
73
74                 public  IMethodRef GetMethodRef (ITypeRef ret_type,
75                         PEAPI.CallConv call_conv, string name, ITypeRef[] param)
76                 {
77                         return new MethodRef (this, call_conv, ret_type, name, param);
78                 }
79
80                 public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
81                 {
82                         return new FieldRef (this, ret_type, name);
83                 }
84
85                 public void Resolve (CodeGen code_gen)
86                 {
87                         if (is_resolved)
88                                 return;
89
90                         PEAPI.Type base_type;
91
92                         base_type = code_gen.TypeManager.GetPeapiType (full_name);
93                         type = Modify (code_gen, base_type);
94
95                         is_resolved = true;
96                 }
97
98                 public IClassRef AsClassRef (CodeGen code_gen)
99                 {
100                         return this;
101                 }
102
103                 public override string ToString ()
104                 {
105                         return FullName;
106                 }
107
108         }
109
110 }
111