2 // Mono.ILASM.BaseTypeRef
5 // Ankit Jain <jankit@novell.com>
7 // Copyright 2006 Novell, Inc (http://www.novell.com)
11 using System
.Collections
;
13 namespace Mono
.ILASM
{
15 public abstract class BaseTypeRef
: ModifiableType
{
16 protected string full_name
;
17 protected string sig_mod
;
18 protected PEAPI
.Type type
;
19 protected bool is_resolved
;
20 protected Hashtable method_table
;
21 protected Hashtable field_table
;
23 protected BaseTypeRef (string full_name
)
24 : this (full_name
, null, null)
28 protected BaseTypeRef (string full_name
, ArrayList conv_list
, string sig_mod
)
30 this.full_name
= full_name
;
31 this.sig_mod
= sig_mod
;
33 if (conv_list
!= null)
34 ConversionList
= conv_list
;
37 public virtual string FullName
{
38 get { return full_name + sig_mod; }
41 public override string SigMod
{
42 get { return sig_mod; }
43 set { sig_mod = value; }
46 public PEAPI
.Type PeapiType
{
50 public bool IsResolved
{
51 get { return is_resolved; }
54 public abstract void Resolve (CodeGen code_gen
);
56 public abstract BaseTypeRef
Clone ();
58 protected abstract BaseMethodRef
CreateMethodRef (BaseTypeRef ret_type
,
59 PEAPI
.CallConv call_conv
, string name
, BaseTypeRef
[] param
, int gen_param_count
);
61 public virtual BaseMethodRef
GetMethodRef (BaseTypeRef ret_type
,
62 PEAPI
.CallConv call_conv
, string name
, BaseTypeRef
[] param
, int gen_param_count
)
64 BaseMethodRef mr
= null;
66 /* Note: FullName not reqd as this is cached per object */
67 string key
= MethodDef
.CreateSignature (ret_type
, call_conv
, name
, param
, gen_param_count
, true);
68 if (method_table
== null)
69 method_table
= new Hashtable ();
71 mr
= (BaseMethodRef
) method_table
[key
];
74 mr
= CreateMethodRef (ret_type
, call_conv
, name
, param
, gen_param_count
);
75 method_table
[key
] = mr
;
81 protected abstract IFieldRef
CreateFieldRef (BaseTypeRef ret_type
, string name
);
83 public virtual IFieldRef
GetFieldRef (BaseTypeRef ret_type
, string name
)
86 string key
= ret_type
.FullName
+ name
;
88 if (field_table
== null)
89 field_table
= new Hashtable ();
91 fr
= (IFieldRef
) field_table
[key
];
94 fr
= CreateFieldRef (ret_type
, name
);
95 field_table
[key
] = fr
;