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 : BaseTypeRef {
21 private static Hashtable s_method_table = new Hashtable ();
23 public PrimitiveTypeRef (PEAPI.PrimitiveType type, string full_name)
27 SigMod = String.Empty;
31 get { return full_name; }
34 public override void Resolve (CodeGen code_gen)
39 // Perform all of the types modifications
40 type = Modify (code_gen, type);
46 /// Primitive types can be created like this System.String instead
47 /// of like a normal type that would be [mscorlib]System.String This
48 /// method returns a proper primitive type if the supplied name is
49 /// the name of a primitive type.
51 public static PrimitiveTypeRef GetPrimitiveType (string full_name)
55 return new PrimitiveTypeRef (PEAPI.PrimitiveType.String, full_name);
57 return new PrimitiveTypeRef (PEAPI.PrimitiveType.Object, full_name);
63 public override BaseMethodRef GetMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
64 string name, BaseTypeRef[] param, int gen_param_count)
66 /* Use FullName also here, as we are caching in a static hashtable */
67 string key = FullName + MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
68 TypeSpecMethodRef mr = s_method_table [key] as TypeSpecMethodRef;
72 //FIXME: generic methodref for primitive type?
73 mr = new TypeSpecMethodRef (this, call_conv, ret_type, name, param, gen_param_count);
74 s_method_table [key] = mr;
78 public override IFieldRef CreateFieldRef (BaseTypeRef ret_type, string name)
80 throw new Exception ("PrimitiveType's can't have fields!");
83 public BaseClassRef AsClassRef (CodeGen code_gen)
86 PEAPI.ClassRef class_ref = code_gen.ExternTable.GetValueClass ("corlib", FullName);
87 ExternTypeRef type_ref = new ExternTypeRef (class_ref, FullName);
89 // TODO: Need to do the rest of the conversion (in order)
91 type_ref.MakeArray ();
95 throw new NotImplementedException ("This method is getting depricated.");