2 // Mono.ILASM.PrimitiveTypeRef
5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
12 using System.Collections;
14 namespace Mono.ILASM {
17 /// Reference to a primitive type, ie string, object, char
19 public class PrimitiveTypeRef : ModifiableType, ITypeRef {
21 private string full_name;
22 private string sig_mod;
23 private PEAPI.Type type;
25 private bool is_resolved;
26 private static Hashtable method_table = new Hashtable ();
28 public PrimitiveTypeRef (PEAPI.PrimitiveType type, string full_name)
31 this.full_name = full_name;
32 sig_mod = String.Empty;
37 get { return full_name; }
40 public string FullName {
41 get { return full_name + sig_mod; }
44 public override string SigMod {
45 get { return sig_mod; }
46 set { sig_mod = value; }
49 public PEAPI.Type PeapiType {
53 public void Resolve (CodeGen code_gen)
58 // Perform all of the types modifications
59 type = Modify (code_gen, type);
65 /// Primitive types can be created like this System.String instead
66 /// of like a normal type that would be [mscorlib]System.String This
67 /// method returns a proper primitive type if the supplied name is
68 /// the name of a primitive type.
70 public static PrimitiveTypeRef GetPrimitiveType (string full_name)
74 return new PrimitiveTypeRef (PEAPI.PrimitiveType.String, full_name);
76 return new PrimitiveTypeRef (PEAPI.PrimitiveType.Object, full_name);
82 public IMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
83 string name, ITypeRef[] param, int gen_param_count)
85 string key = full_name + MethodDef.CreateSignature (ret_type, name, param, gen_param_count) + sig_mod;
86 TypeSpecMethodRef mr = method_table [key] as TypeSpecMethodRef;
90 //FIXME: generic methodref for primitive type?
91 mr = new TypeSpecMethodRef (this, ret_type, call_conv, name, param, gen_param_count);
92 method_table [key] = mr;
96 public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
98 return new TypeSpecFieldRef (this, ret_type, name);
101 public IClassRef AsClassRef (CodeGen code_gen)
104 PEAPI.ClassRef class_ref = code_gen.ExternTable.GetValueClass ("corlib", FullName);
105 ExternTypeRef type_ref = new ExternTypeRef (class_ref, FullName);
107 // TODO: Need to do the rest of the conversion (in order)
109 type_ref.MakeArray ();
113 throw new NotImplementedException ("This method is getting depricated.");