2010-03-17 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mcs / ilasm / codegen / GlobalMethodRef.cs
index 66a7789a7df96e3bb46c26a18870650538737e41..6a47aa002d1cd3c184c6f092b85376d47d267d8c 100644 (file)
@@ -13,58 +13,26 @@ using System.Collections;
 
 namespace Mono.ILASM {
 
-        public class GlobalMethodRef : IMethodRef {
+        public class GlobalMethodRef : BaseMethodRef {
 
-                private ITypeRef ret_type;
-                private string name;
-                private ITypeRef[] param;
-                private PEAPI.CallConv call_conv;
-
-                private PEAPI.Method peapi_method;
-               private bool is_resolved;
-               private int gen_param_count;
-
-                public GlobalMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
-                                string name, ITypeRef[] param, int gen_param_count)
+                public GlobalMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
+                                string name, BaseTypeRef[] param, int gen_param_count)
+                        : base (null, call_conv, ret_type, name, param, gen_param_count)
                 {
-                        this.ret_type = ret_type;
-                        this.call_conv = call_conv;
-                        this.name = name;
-                        this.param = param;
-                       this.gen_param_count = gen_param_count;
-                       if (gen_param_count > 0)
-                               CallConv |= PEAPI.CallConv.Generic;
-
-                       is_resolved = false;
-                }
-
-                public PEAPI.Method PeapiMethod {
-                        get { return peapi_method; }
                 }
 
-               public PEAPI.CallConv CallConv {
-                       get { return call_conv; }
-                       set { call_conv = value; }
-               }
-
-               public ITypeRef Owner {
-                       get { return null; }
-               }
-
-                public void Resolve (CodeGen code_gen)
+                public override void Resolve (CodeGen code_gen)
                 {
                        if (is_resolved)
                                return;
 
-                        string sig;
-
                         if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
-                                sig = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
+                                string sig = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, false);
                                 peapi_method = code_gen.ResolveMethod (sig);
                         } else {
                                 ArrayList opt_list = new ArrayList ();
                                 bool in_opt = false;
-                                foreach (ITypeRef type in param) {
+                                foreach (BaseTypeRef type in param) {
                                         if (type is SentinelTypeRef) {
                                                 in_opt = true;
                                         } else if (in_opt) {
@@ -72,8 +40,10 @@ namespace Mono.ILASM {
                                                 opt_list.Add (type.PeapiType);
                                         }
                                 }
-                                sig = MethodDef.CreateVarargSignature (ret_type, name, param);
-                                peapi_method = code_gen.ResolveVarargMethod (sig, code_gen,
+
+                                string sig_only_required_params = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, false);
+                                string sig_with_optional_params = MethodDef.CreateSignature (ret_type, call_conv, name, param, gen_param_count, true);
+                                peapi_method = code_gen.ResolveVarargMethod (sig_only_required_params, sig_with_optional_params, code_gen,
                                                 (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
                         }