2 // Mono.ILASM.LdtokenInstr
5 // Jackson Harper (Jackson@LatitudeGeo.com)
7 // (C) 2003 Jackson Harper, All rights reserved
13 namespace Mono
.ILASM
{
15 public class LdtokenInstr
: IInstr
{
17 private IFieldRef field_ref
;
18 private BaseMethodRef method_ref
;
19 private BaseTypeRef type_ref
;
21 public LdtokenInstr (IFieldRef field_ref
, Location loc
)
24 this.field_ref
= field_ref
;
27 public LdtokenInstr (BaseMethodRef method_ref
, Location loc
)
30 this.method_ref
= method_ref
;
33 public LdtokenInstr (BaseTypeRef type_ref
, Location loc
)
36 this.type_ref
= type_ref
;
39 public override void Emit (CodeGen code_gen
, MethodDef meth
,
40 PEAPI
.CILInstructions cil
)
42 if (field_ref
!= null) {
43 field_ref
.Resolve (code_gen
);
44 cil
.FieldInst (PEAPI
.FieldOp
.ldtoken
,
45 field_ref
.PeapiField
);
46 } else if (method_ref
!= null) {
47 method_ref
.Resolve (code_gen
);
48 cil
.MethInst (PEAPI
.MethodOp
.ldtoken
,
49 method_ref
.PeapiMethod
);
50 } else if (type_ref
!= null) {
51 type_ref
.Resolve (code_gen
);
52 cil
.TypeInst (PEAPI
.TypeOp
.ldtoken
,