2 // Mono.ILASM.ExternTypeRef
5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
12 using System
.Collections
;
14 namespace Mono
.ILASM
{
17 /// A reference to a type in another assembly
19 public class ExternTypeRef
: ModifiableType
, IClassRef
{
21 private PEAPI
.Type type
;
22 private ExternRef extern_ref
;
23 private string full_name
;
24 private string sig_mod
;
25 private bool is_valuetype
;
26 private ExternTable extern_table
;
28 private bool is_resolved
;
30 private Hashtable method_table
;
31 private Hashtable field_table
;
33 public ExternTypeRef (ExternRef extern_ref
, string full_name
,
34 bool is_valuetype
, ExternTable extern_table
)
36 this.extern_ref
= extern_ref
;
37 this.full_name
= full_name
;
38 this.is_valuetype
= is_valuetype
;
39 this.extern_table
= extern_table
;
40 sig_mod
= String
.Empty
;
42 method_table
= new Hashtable ();
43 field_table
= new Hashtable ();
48 private ExternTypeRef (ExternRef extern_ref
, string full_name
,
49 bool is_valuetype
, ExternTable extern_table
,
50 ArrayList conv_list
) : this (extern_ref
, full_name
,
51 is_valuetype
, extern_table
)
53 ConversionList
= conv_list
;
56 public ExternTypeRef
Clone ()
58 return new ExternTypeRef (extern_ref
, FullName
, is_valuetype
,
59 extern_table
, (ArrayList
) ConversionList
.Clone ());
62 public PEAPI
.Type PeapiType
{
66 public PEAPI
.Class PeapiClass
{
67 get { return type as PEAPI.Class; }
70 public string FullName
{
71 get { return full_name + sig_mod; }
75 public override string SigMod
{
76 get { return sig_mod; }
77 set { sig_mod = value; }
80 public void Resolve (CodeGen code_gen
)
86 type
= extern_ref
.GetValueType (full_name
);
88 type
= extern_ref
.GetType (full_name
);
90 type
= Modify (code_gen
, type
);
95 public void MakeValueClass ()
100 public IMethodRef
GetMethodRef (ITypeRef ret_type
, PEAPI
.CallConv call_conv
,
101 string name
, ITypeRef
[] param
)
103 string sig
= MethodDef
.CreateSignature (name
, param
);
104 ExternMethodRef mr
= method_table
[sig
] as ExternMethodRef
;
107 mr
= new ExternMethodRef (this, ret_type
, call_conv
, name
, param
);
108 method_table
[sig
] = mr
;
114 public IFieldRef
GetFieldRef (ITypeRef ret_type
, string name
)
116 ExternFieldRef fr
= field_table
[name
] as ExternFieldRef
;
119 fr
= new ExternFieldRef (this, ret_type
, name
);
120 field_table
[name
] = fr
;