2 // Mono.ILASM.MethodRef
5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
12 using System.Collections;
14 namespace Mono.ILASM {
16 public class MethodRef : IMethodRef {
18 private TypeRef owner;
19 private PEAPI.CallConv call_conv;
20 private ITypeRef ret_type;
22 private ITypeRef[] param;
24 private PEAPI.Method peapi_method;
25 private bool is_resolved;
26 private int gen_param_count;
28 public MethodRef (TypeRef owner, PEAPI.CallConv call_conv,
29 ITypeRef ret_type, string name, ITypeRef[] param, int gen_param_count)
32 this.call_conv = call_conv;
33 this.ret_type = ret_type;
36 this.gen_param_count = gen_param_count;
40 public PEAPI.Method PeapiMethod {
41 get { return peapi_method; }
44 public PEAPI.CallConv CallConv {
45 get { return call_conv; }
46 set { call_conv = value; }
49 public ITypeRef Owner {
53 public void Resolve (CodeGen code_gen)
58 TypeDef owner_def = code_gen.TypeManager[owner.FullName];
59 if (owner_def == null)
60 throw new Exception (String.Format ("Reference to undefined class '{0}'", owner.FullName));
71 if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
72 sig = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
73 peapi_method = owner_def.ResolveMethod (sig, code_gen);
75 sig = MethodDef.CreateVarargSignature (ret_type, name, param);
76 ArrayList opt_list = new ArrayList ();
78 foreach (ITypeRef type in param) {
79 if (type is SentinelTypeRef) {
82 type.Resolve (code_gen);
83 opt_list.Add (type.PeapiType);
86 peapi_method = owner_def.ResolveVarargMethod (sig, code_gen,
87 (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));