1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
//
// Mono.ILASM.BaseTypeRef
//
// Author(s):
// Ankit Jain <jankit@novell.com>
//
// Copyright 2006 Novell, Inc (http://www.novell.com)
//
using System;
using System.Collections;
namespace Mono.ILASM {
public abstract class BaseTypeRef : ModifiableType {
protected string full_name;
protected string sig_mod;
protected PEAPI.Type type;
protected bool is_resolved;
protected Hashtable method_table;
protected Hashtable field_table;
protected BaseTypeRef (string full_name)
: this (full_name, null, null)
{
}
protected BaseTypeRef (string full_name, ArrayList conv_list, string sig_mod)
{
this.full_name = full_name;
this.sig_mod = sig_mod;
is_resolved = false;
if (conv_list != null)
ConversionList = conv_list;
}
public virtual string FullName {
get { return full_name + sig_mod; }
}
public override string SigMod {
get { return sig_mod; }
set { sig_mod = value; }
}
public PEAPI.Type PeapiType {
get { return type; }
}
public bool IsResolved {
get { return is_resolved; }
}
public abstract void Resolve (CodeGen code_gen);
protected abstract BaseMethodRef CreateMethodRef (BaseTypeRef ret_type,
PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count);
public virtual BaseMethodRef GetMethodRef (BaseTypeRef ret_type,
PEAPI.CallConv call_conv, string name, BaseTypeRef[] param, int gen_param_count)
{
BaseMethodRef mr = null;
/* Note: FullName not reqd as this is cached per object */
string key = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
if (method_table == null)
method_table = new Hashtable ();
else
mr = (BaseMethodRef) method_table [key];
if (mr == null) {
mr = CreateMethodRef (ret_type, call_conv, name, param, gen_param_count);
method_table [key] = mr;
}
return mr;
}
protected abstract IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name);
public virtual IFieldRef GetFieldRef (BaseTypeRef ret_type, string name)
{
IFieldRef fr = null;
string key = ret_type.FullName + name;
if (field_table == null)
field_table = new Hashtable ();
else
fr = (IFieldRef) field_table [key];
if (fr == null) {
fr = CreateFieldRef (ret_type, name);
field_table [key] = fr;
}
return fr;
}
}
}
|