2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / ilasm / codegen / CalliInstr.cs
1 //
2 // Mono.ILASM.CalliInstr
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
13
14 namespace Mono.ILASM {
15
16         public class CalliInstr : IInstr {
17
18                 private PEAPI.CallConv call_conv;
19                 private ITypeRef ret_type;
20                 private ITypeRef[] param;
21
22                 public CalliInstr (PEAPI.CallConv call_conv, ITypeRef ret_type,
23                                    ITypeRef[] param, Location loc)
24                         : base (loc)
25                 {
26                         this.call_conv = call_conv;
27                         this.ret_type = ret_type;
28                         this.param = param;
29                 }
30
31                 public override void Emit (CodeGen code_gen, MethodDef meth,
32                                            PEAPI.CILInstructions cil)
33                 {
34                         PEAPI.Type[] param_array;
35                         PEAPI.CalliSig callisig;
36
37                         if (param != null) {
38                                 param_array = new PEAPI.Type[param.Length];
39                                 int count = 0;
40                                 foreach (ITypeRef typeref in param) {
41                                         typeref.Resolve (code_gen);
42                                         param_array[count++] = typeref.PeapiType;
43                                 }
44                         } else {
45                                 param_array = new PEAPI.Type[0];
46                         }
47
48                         ret_type.Resolve (code_gen);
49                         callisig = new PEAPI.CalliSig (call_conv,
50                                         ret_type.PeapiType, param_array);
51
52                         cil.calli (callisig);
53                 }
54         }
55
56 }