I create a dynamic method, i.e.:
class MyClass
{
private void object _o = <whatever>;
void CreateDynamicMethod()
{
DynamicMethod dm = new DynamicMethod("Test", ...);
// emit various IL
// need to push _o onto stack here
}
}
The 2nd comment, I want to push the value of _o currently onto the stack. I don't want to push the reference of _o as it will change as I build the dynamic method.
So lets say _o = 5, I want to push the 5, if _o contains a List, I want to push that, if it contains a string, I want to push the string.
The dynamic method (Test) is a static method and its obviously not going to have the this pointer of MyClass to get the field. I can't even put it in a static variable as that will be accessed during the execution of Test() and not while I'm building the method.
Even if I had the this pointer, the _o is not going to have the right value at Test() execution time.
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire