dlr bug
[mcs.git] / ilasm / codegen / BaseTypeRef.cs
blobb690e4d792c078feed1b9d622d18afc3c13ad1bc
1 //
2 // Mono.ILASM.BaseTypeRef
3 //
4 // Author(s):
5 // Ankit Jain <jankit@novell.com>
6 //
7 // Copyright 2006 Novell, Inc (http://www.novell.com)
8 //
10 using System;
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;
32 is_resolved = false;
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 {
47 get { return type; }
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 ();
70 else
71 mr = (BaseMethodRef) method_table [key];
73 if (mr == null) {
74 mr = CreateMethodRef (ret_type, call_conv, name, param, gen_param_count);
75 method_table [key] = mr;
78 return mr;
81 protected abstract IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name);
83 public virtual IFieldRef GetFieldRef (BaseTypeRef ret_type, string name)
85 IFieldRef fr = null;
86 string key = ret_type.FullName + name;
88 if (field_table == null)
89 field_table = new Hashtable ();
90 else
91 fr = (IFieldRef) field_table [key];
93 if (fr == null) {
94 fr = CreateFieldRef (ret_type, name);
95 field_table [key] = fr;
98 return fr;