**** Merged from MCS ****
[mono-project.git] / mcs / ilasm / codegen / CalliInstr.cs
blobc995857e40868d54bab93ed783f273fc34e39b05
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 //
11 using System;
14 namespace Mono.ILASM {
16 public class CalliInstr : IInstr {
18 private PEAPI.CallConv call_conv;
19 private ITypeRef ret_type;
20 private ITypeRef[] param;
22 public CalliInstr (PEAPI.CallConv call_conv, ITypeRef ret_type,
23 ITypeRef[] param, Location loc)
24 : base (loc)
26 this.call_conv = call_conv;
27 this.ret_type = ret_type;
28 this.param = param;
31 public override void Emit (CodeGen code_gen, MethodDef meth,
32 PEAPI.CILInstructions cil)
34 PEAPI.Type[] param_array;
35 PEAPI.CalliSig callisig;
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;
44 } else {
45 param_array = new PEAPI.Type[0];
48 ret_type.Resolve (code_gen);
49 callisig = new PEAPI.CalliSig (call_conv,
50 ret_type.PeapiType, param_array);
52 cil.calli (callisig);