In ilasm/codegen:
[mono.git] / mcs / ilasm / codegen / PrimitiveTypeRef.cs
index ecfb9a9866c0d735c0d254d40c93d9864e073ae9..5633f339baed904e81e955072d77af11bd61b8b4 100644 (file)
@@ -9,6 +9,7 @@
 
 
 using System;
+using System.Collections;
 
 namespace Mono.ILASM {
 
@@ -22,6 +23,7 @@ namespace Mono.ILASM {
                 private PEAPI.Type type;
 
                 private bool is_resolved;
+                private static Hashtable method_table = new Hashtable ();
 
                 public PrimitiveTypeRef (PEAPI.PrimitiveType type, string full_name)
                 {
@@ -31,6 +33,10 @@ namespace Mono.ILASM {
                         is_resolved = false;
                 }
 
+               public string Name {
+                       get { return full_name; }
+               }
+
                 public string FullName {
                         get { return full_name + sig_mod; }
                 }
@@ -74,9 +80,17 @@ namespace Mono.ILASM {
                 }
 
                 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)