This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[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, ITypeRef[] param)
23                 {
24                         this.call_conv = call_conv;
25                         this.ret_type = ret_type;
26                         this.param = param;
27                 }
28
29                 public void Emit (CodeGen code_gen, MethodDef meth,
30                                   PEAPI.CILInstructions cil)
31                 {
32                         PEAPI.Type[] param_array;
33                         PEAPI.CalliSig callisig;
34
35                         if (param != null) {
36                                 param_array = new PEAPI.Type[param.Length];
37                                 int count = 0;
38                                 foreach (ITypeRef typeref in param) {
39                                         typeref.Resolve (code_gen);
40                                         param_array[count++] = typeref.PeapiType;
41                                 }
42                         } else {
43                                 param_array = new PEAPI.Type[0];
44                         }
45
46                         ret_type.Resolve (code_gen);
47                         callisig = new PEAPI.CalliSig (call_conv,
48                                         ret_type.PeapiType, param_array);
49
50                         cil.calli (callisig);
51                 }
52         }
53
54 }