2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / ilasm / codegen / LdtokenInstr.cs
index ceea30cd27e898be030991b04ec1b4193b8c832e..76f6cbd8b9bb9fc1306b40d1ebd0e40faa7c84cb 100644 (file)
@@ -16,18 +16,28 @@ namespace Mono.ILASM {
 
                 private IFieldRef field_ref;
                 private IMethodRef method_ref;
+                private ITypeRef type_ref;
 
-                public LdtokenInstr (IFieldRef field_ref)
+                public LdtokenInstr (IFieldRef field_ref, Location loc)
+                       : base (loc)
                 {
                         this.field_ref = field_ref;
                 }
 
-                public LdtokenInstr (IMethodRef method_ref)
+                public LdtokenInstr (IMethodRef method_ref, Location loc)
+                       : base (loc)
                 {
                         this.method_ref = method_ref;
                 }
 
-                public void Emit (CodeGen code_gen, PEAPI.CILInstructions cil)
+                public LdtokenInstr (ITypeRef 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);
@@ -37,6 +47,10 @@ namespace Mono.ILASM {
                                 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);
                         }
                 }