diff options
Diffstat (limited to 'mcs/ilasm/codegen/LdtokenInstr.cs')
-rw-r--r-- | mcs/ilasm/codegen/LdtokenInstr.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/mcs/ilasm/codegen/LdtokenInstr.cs b/mcs/ilasm/codegen/LdtokenInstr.cs new file mode 100644 index 00000000000..0accc421b63 --- /dev/null +++ b/mcs/ilasm/codegen/LdtokenInstr.cs @@ -0,0 +1,60 @@ +// +// Mono.ILASM.LdtokenInstr +// +// Author(s): +// Jackson Harper (Jackson@LatitudeGeo.com) +// +// (C) 2003 Jackson Harper, All rights reserved +// + + +using System; + +namespace Mono.ILASM { + + public class LdtokenInstr : IInstr { + + private IFieldRef field_ref; + private BaseMethodRef method_ref; + private BaseTypeRef type_ref; + + public LdtokenInstr (IFieldRef field_ref, Location loc) + : base (loc) + { + this.field_ref = field_ref; + } + + public LdtokenInstr (BaseMethodRef method_ref, Location loc) + : base (loc) + { + this.method_ref = method_ref; + } + + public LdtokenInstr (BaseTypeRef type_ref, Location loc) + : base (loc) + { + this.type_ref = type_ref; + } + + public override void Emit (CodeGen code_gen, MethodDef meth, + PEAPI.CILInstructions cil) + { + if (field_ref != null) { + field_ref.Resolve (code_gen); + cil.FieldInst (PEAPI.FieldOp.ldtoken, + field_ref.PeapiField); + } else if (method_ref != null) { + method_ref.Resolve (code_gen); + cil.MethInst (PEAPI.MethodOp.ldtoken, + method_ref.PeapiMethod); + } else if (type_ref != null) { + type_ref.Resolve (code_gen); + cil.TypeInst (PEAPI.TypeOp.ldtoken, + type_ref.PeapiType); + } + } + + } + +} + |