oop - CIL instructions unexpected return value -
i trying create il-instructions manually learning purposes, have run small problem.
i have simple structure interface: "myinterface" single method: "handle", class called "addtwo" implements "myinterface" , "program" class entrymethod. il-dump looks this:
.class interface public abstract auto ansi myinterface<tinput,toutput> { .method public hidebysig newslot abstract virtual instance !toutput handle(!tinput a_1) cil managed { } // end of method myinterface::handle } // end of class myinterface .class public auto ansi plustwo extends [mscorlib]system.object implements class myinterface<int32,int32> { .method public hidebysig newslot virtual final instance int32 handle(int32 x) cil managed { // code size 13 (0xd) .maxstack 2 il_0000: ldarg 0 il_0004: nop il_0005: nop il_0006: ldc.i4 0x2 il_000b: add il_000c: ret } // end of method plustwo::handle } // end of class plustwo .class public auto ansi program extends [mscorlib]system.object { .method public static int32 main() cil managed { .entrypoint // code size 34 (0x22) .maxstack 2 .locals init (int32 v_0) il_0000: newobj instance void plustwo::.ctor() il_0005: ldc.i4 0xa il_000a: callvirt instance !1 class myinterface<int32,int32>::handle(!0) il_000f: stloc v_0 il_0013: nop il_0014: nop il_0015: ldloc v_0 il_0019: nop il_001a: nop il_001b: ldc.i4 0x5 il_0020: add il_0021: ret } // end of method program::main } // end of class program
in above expect output be: 17, instead random high integer changes each test. looks memory address or something. can tell, looking @ generated il above, problem might be? appreciated.
Comments
Post a Comment