* CalliInstr.cs: New file - The calli instruction
[mono.git] / mcs / ilasm / codegen / LdtokenInstr.cs
1 //
2 // Mono.ILASM.LdtokenInstr
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 namespace Mono.ILASM {
14
15         public class LdtokenInstr : IInstr {
16
17                 private IFieldRef field_ref;
18                 private IMethodRef method_ref;
19
20                 public LdtokenInstr (IFieldRef field_ref)
21                 {
22                         this.field_ref = field_ref;
23                 }
24
25                 public LdtokenInstr (IMethodRef method_ref)
26                 {
27                         this.method_ref = method_ref;
28                 }
29
30                 public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
31                 {
32                         if (field_ref != null) {
33                                 field_ref.Resolve (code_gen);
34                                 cil.FieldInst (PEAPI.FieldOp.ldtoken,
35                                                 field_ref.PeapiField);
36                         } else if (method_ref != null) {
37                                 method_ref.Resolve (code_gen);
38                                 cil.MethInst (PEAPI.MethodOp.ldtoken,
39                                                 method_ref.PeapiMethod);
40                         }
41                 }
42
43         }
44
45 }
46