Load an object reference onto the stack ???

V

VivekR

Hi

I have a class CodeGen in which GenerateILBody is a method that uses
ILGenerator.Emit to create the IL code as method body for a dynamic
method DynMethod. GenerateILBody at runtime must call another method
CallBack of the class CodeGen.

All i have to do is to emit the IL code that loads the object reference
of CodeGen onto the stack, which means I must emit IL in GenerateILBody
to load 'this', which may look like:-

ilgen.Emit(OpCodeToLoad, this);

The this here refers to the CodeGen object reference, and at runtime
will have to use the reference to call the CallBack method.

But there is no overload in ILgenerator.Emit that takes an object
reference.

Please let me know how to load an object reference onto the stack in
IL.

Thanks
Vivek Ragunathan
 
B

Barry Kelly

I have a class CodeGen in which GenerateILBody is a method that uses
ILGenerator.Emit to create the IL code as method body for a dynamic
method DynMethod. GenerateILBody at runtime must call another method
CallBack of the class CodeGen.

I have replied already in another newsgroup.

-- Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top