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;
36 public string FullName {
37 get { return full_name + sig_mod; }
40 public override string SigMod {
41 get { return sig_mod; }
42 set { sig_mod = value; }
45 public PEAPI.Type PeapiType {
49 public void Resolve (CodeGen code_gen)
54 // Perform all of the types modifications
55 type = Modify (code_gen, type);
61 /// Primitive types can be created like this System.String instead
62 /// of like a normal type that would be [mscorlib]System.String This
63 /// method returns a proper primitive type if the supplied name is
64 /// the name of a primitive type.
66 public static PrimitiveTypeRef GetPrimitiveType (string full_name)
70 return new PrimitiveTypeRef (PEAPI.PrimitiveType.String, full_name);
72 return new PrimitiveTypeRef (PEAPI.PrimitiveType.Object, full_name);
78 public IMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
79 string name, ITypeRef[] param)
81 string key = full_name + MethodDef.CreateSignature (ret_type, name, param) + sig_mod;
82 TypeSpecMethodRef mr = method_table [key] as TypeSpecMethodRef;
86 mr = new TypeSpecMethodRef (this, ret_type, call_conv, name, param);
87 method_table [key] = mr;
91 public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
93 return new TypeSpecFieldRef (this, ret_type, name);
96 public IClassRef AsClassRef (CodeGen code_gen)
99 PEAPI.ClassRef class_ref = code_gen.ExternTable.GetValueClass ("corlib", FullName);
100 ExternTypeRef type_ref = new ExternTypeRef (class_ref, FullName);
102 // TODO: Need to do the rest of the conversion (in order)
104 type_ref.MakeArray ();
108 throw new NotImplementedException ("This method is getting depricated.");