New test.
[mono.git] / mcs / ilasm / codegen / GlobalMethodRef.cs
1 //
2 // Mono.ILASM.GlobalMethodRef
3 //
4 // Author(s):
5 //  Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Jackson Harper, All rights reserved
8 //
9
10
11 using System;
12 using System.Collections;
13
14 namespace Mono.ILASM {
15
16         public class GlobalMethodRef : BaseMethodRef {
17
18                 public GlobalMethodRef (BaseTypeRef ret_type, PEAPI.CallConv call_conv,
19                                 string name, BaseTypeRef[] param, int gen_param_count)
20                         : base (null, call_conv, ret_type, name, param, gen_param_count)
21                 {
22                 }
23
24                 public override void Resolve (CodeGen code_gen)
25                 {
26                         if (is_resolved)
27                                 return;
28
29                         string sig;
30
31                         if ((call_conv & PEAPI.CallConv.Vararg) == 0) {
32                                 sig = MethodDef.CreateSignature (ret_type, name, param, gen_param_count);
33                                 peapi_method = code_gen.ResolveMethod (sig);
34                         } else {
35                                 ArrayList opt_list = new ArrayList ();
36                                 bool in_opt = false;
37                                 foreach (BaseTypeRef type in param) {
38                                         if (type is SentinelTypeRef) {
39                                                 in_opt = true;
40                                         } else if (in_opt) {
41                                                 type.Resolve (code_gen);
42                                                 opt_list.Add (type.PeapiType);
43                                         }
44                                 }
45                                 sig = MethodDef.CreateVarargSignature (ret_type, name, param);
46                                 peapi_method = code_gen.ResolveVarargMethod (sig, code_gen,
47                                                 (PEAPI.Type[]) opt_list.ToArray (typeof (PEAPI.Type)));
48                         }
49
50                         peapi_method.AddCallConv (call_conv);
51                         
52                         is_resolved = true;
53                 }
54
55         }
56
57 }
58