using System;
+using System.Collections;
namespace Mono.ILASM {
/// <summary>
/// Reference to a primitive type, ie string, object, char
/// </summary>
- public class PrimitiveTypeRef : PeapiTypeRef, ITypeRef {
+ public class PrimitiveTypeRef : ModifiableType, ITypeRef {
- public PrimitiveTypeRef (PEAPI.PrimitiveType prim_type,
- string full_name) : base (prim_type, full_name)
+ private string full_name;
+ private string sig_mod;
+ private PEAPI.Type type;
+
+ private bool is_resolved;
+ private static Hashtable method_table = new Hashtable ();
+
+ public PrimitiveTypeRef (PEAPI.PrimitiveType type, string full_name)
+ {
+ this.type = type;
+ this.full_name = full_name;
+ sig_mod = String.Empty;
+ is_resolved = false;
+ }
+
+ public string Name {
+ get { return full_name; }
+ }
+
+ public 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 void Resolve (CodeGen code_gen)
{
+ if (is_resolved)
+ return;
+
+ // Perform all of the types modifications
+ type = Modify (code_gen, type);
+ is_resolved = true;
}
/// <summary>
}
public IMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
- string name, ITypeRef[] param)
+ string name, ITypeRef[] param, int gen_param_count)
{
- return new TypeSpecMethodRef (this, ret_type, call_conv, name, param);
+ string key = full_name + MethodDef.CreateSignature (ret_type, name, param, gen_param_count) + sig_mod;
+ TypeSpecMethodRef mr = method_table [key] as TypeSpecMethodRef;
+ if (mr != null)
+ return mr;
+
+ //FIXME: generic methodref for primitive type?
+ mr = new TypeSpecMethodRef (this, ret_type, call_conv, name, param, gen_param_count);
+ method_table [key] = mr;
+ return mr;
}
public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
public IClassRef AsClassRef (CodeGen code_gen)
{
+ /*
PEAPI.ClassRef class_ref = code_gen.ExternTable.GetValueClass ("corlib", FullName);
ExternTypeRef type_ref = new ExternTypeRef (class_ref, FullName);
type_ref.MakeArray ();
return type_ref;
+ */
+ throw new NotImplementedException ("This method is getting depricated.");
}
}