Is there a way to look up into the stack via Reflection.Emit Opcodes? For example, let’s say I want to push X, and then push Y, and then I need to get at the value of X…how do I go about that?
True, I could store y into a local variable, and then later load Y again, but that’s a bit of a round-about way of going at it.
There is no direct way to do this. See Reflection.Emit – access topmost-but-one item from stack for another related question.