2 // Mono.ILASM.MethodPointerTypeRef
5 // Jackson Harper (jackson@ximian.com)
7 // Copyright 2004 Novell, Inc (http://www.novell.com)
12 using System.Collections;
14 namespace Mono.ILASM {
16 public class MethodPointerTypeRef : ModifiableType, ITypeRef {
18 private PEAPI.CallConv callconv;
20 private ArrayList param_list;
21 private PEAPI.Type type;
22 private string full_name;
23 private string sig_mod;
24 private bool is_resolved;
26 public MethodPointerTypeRef (PEAPI.CallConv callconv, ITypeRef ret, ArrayList param_list)
28 this.callconv = callconv;
30 this.param_list = param_list;
32 // We just need these to not break the interface
33 full_name = String.Empty;
34 sig_mod = String.Empty;
37 public string FullName {
38 get { return full_name + sig_mod; }
41 public override string SigMod {
42 get { return sig_mod; }
43 set { sig_mod = value; }
46 public PEAPI.Type PeapiType {
52 public void Resolve (CodeGen code_gen)
57 PEAPI.Type [] arg_array;
58 PEAPI.Type [] opt_array;
59 bool is_vararg = false;
61 if (param_list != null) {
62 ArrayList opt_list = new ArrayList ();
63 ArrayList arg_list = new ArrayList ();
66 int max = param_list.Count;
68 for (int i = 0; i < max; i++) {
69 ParamDef param = (ParamDef) param_list [i];
71 if (param.IsSentinel ()) {
74 param.Type.Resolve (code_gen);
76 param.Type.Resolve (code_gen);
77 opt_list.Add (param.Type.PeapiType);
79 param.Type.Resolve (code_gen);
80 arg_list.Add (param.Type.PeapiType);
84 arg_array = (PEAPI.Type []) arg_list.ToArray (typeof (PEAPI.Type));
85 opt_array = (PEAPI.Type []) opt_list.ToArray (typeof (PEAPI.Type));
87 arg_array = new PEAPI.Type [0];
88 opt_array = new PEAPI.Type [0];
91 ret.Resolve (code_gen);
93 type = new PEAPI.MethPtrType (callconv, ret.PeapiType, arg_array, is_vararg, opt_array);
94 type = Modify (code_gen, type);
99 public IMethodRef GetMethodRef (ITypeRef ret_type, PEAPI.CallConv call_conv,
100 string name, ITypeRef[] param, int gen_param_count)
102 return new TypeSpecMethodRef (this, ret_type, call_conv, name, param, gen_param_count);
105 public IFieldRef GetFieldRef (ITypeRef ret_type, string name)
107 return new TypeSpecFieldRef (this, ret_type, name);