Hey Jan,

On Mon, Apr 26, 2010 at 2:04 PM, Jan <jan.blessen...@gmail.com> wrote:
> If I now create a usage of the variable with (OpCodes.Stloc, loc0) I
> always get a OpCodes.Stloc, with Emit I get a OpCodes.Stloc.0 or a
> OpCodes.Stloc.1 for the first and second defined variable.
> With Cecil it looks for me I have to do this by hand, where I have to
> be sure that the ordering of the variables is stable
> (OpCodes.Stloc_0). How can I be sure that I am refering to the right
> slot, or is there a way to do it like with Emit?

What you can do is to emit Stloc and Ldoc and pass the
VariableDefinition. When you're done with the method, you can call

body.Optimize ()

And it will turn the ldloc into ldloc.0.

Optimize is an extension method in Mono.Cecil.Rocks.

-- 
Jb Evain  <j...@nurv.fr>

-- 
--
mono-cecil

Subscription settings: http://groups.google.com/group/mono-cecil/subscribe?hl=en

Reply via email to