5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
11 using System.Collections;
13 namespace Mono.ILASM {
16 /// Reference to a type in the module being compiled.
18 public class TypeRef : ModifiableType, IClassRef {
21 private Location location;
22 private string full_name;
23 private string sig_mod;
24 private PEAPI.Type type;
25 private bool is_valuetype;
26 private Hashtable p_genericinst_table;
28 private bool is_resolved;
30 public static readonly TypeRef Ellipsis = new TypeRef ("ELLIPSIS", false, null);
31 public static readonly TypeRef Any = new TypeRef ("any", false, null);
33 public TypeRef (string full_name, bool is_valuetype, Location location)
34 : this (full_name, is_valuetype, location, null, null)
38 public TypeRef (string full_name, bool is_valuetype, Location location, ArrayList conv_list, string sig_mod)
40 this.full_name = full_name;
41 this.location = location;
42 this.is_valuetype = is_valuetype;
43 this.sig_mod = sig_mod;
44 if (conv_list != null)
45 ConversionList = conv_list;
49 public string FullName {
50 get { return full_name + sig_mod; }
53 public override string SigMod {
54 get { return sig_mod; }
55 set { sig_mod = value; }
58 public PEAPI.Type PeapiType {
62 public PEAPI.Class PeapiClass {
63 get { return type as PEAPI.Class; }
66 public IClassRef Clone ()
68 return new TypeRef (full_name, is_valuetype, location, (ArrayList) ConversionList.Clone (), sig_mod);
71 public bool IsResolved {
72 get { return is_resolved; }
75 public void MakeValueClass ()
80 public GenericTypeInst GetGenericTypeInst (GenericArguments gen_args)
82 return new GenericTypeInst (this, gen_args, is_valuetype);
85 public PEAPI.Type ResolveInstance (CodeGen code_gen, GenericArguments gen_args)
87 PEAPI.GenericTypeInst gtri = null;
88 string sig = gen_args.ToString ();
90 if (p_genericinst_table == null)
91 p_genericinst_table = new Hashtable ();
93 gtri = p_genericinst_table [sig] as PEAPI.GenericTypeInst;
99 gtri = new PEAPI.GenericTypeInst (PeapiType, gen_args.Resolve (code_gen));
100 p_genericinst_table [sig] = gtri;
106 public IMethodRef GetMethodRef (ITypeRef ret_type,
107 PEAPI.CallConv call_conv, string name, ITypeRef[] param, int gen_param_count)
109 return new MethodRef (this, call_conv, ret_type, name, param, gen_param_count);
112 public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
114 return new FieldRef (this, ret_type, name);
117 public void Resolve (CodeGen code_gen)
122 PEAPI.Type base_type;
124 base_type = code_gen.TypeManager.GetPeapiType (full_name);
126 if (base_type == null) {
127 code_gen.Report.Error ("Reference to undefined class '" +
131 type = Modify (code_gen, base_type);
136 public IClassRef AsClassRef (CodeGen code_gen)
141 public override string ToString ()