This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[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                 private ITypeRef type_ref;
20
21                 public LdtokenInstr (IFieldRef field_ref)
22                 {
23                         this.field_ref = field_ref;
24                 }
25
26                 public LdtokenInstr (IMethodRef method_ref)
27                 {
28                         this.method_ref = method_ref;
29                 }
30
31                 public LdtokenInstr (ITypeRef type_ref)
32                 {
33                         this.type_ref = type_ref;
34                 }
35
36                 public void Emit (CodeGen code_gen, MethodDef meth,
37                                   PEAPI.CILInstructions cil)
38                 {
39                         if (field_ref != null) {
40                                 field_ref.Resolve (code_gen);
41                                 cil.FieldInst (PEAPI.FieldOp.ldtoken,
42                                                 field_ref.PeapiField);
43                         } else if (method_ref != null) {
44                                 method_ref.Resolve (code_gen);
45                                 cil.MethInst (PEAPI.MethodOp.ldtoken,
46                                                 method_ref.PeapiMethod);
47                         } else if (type_ref != null) {
48                                 type_ref.Resolve (code_gen);
49                                 cil.TypeInst (PEAPI.TypeOp.ldtoken,
50                                                 type_ref.PeapiType);
51                         }
52                 }
53
54         }
55
56 }
57