CK.Reflection.ILGeneratorExtension.StLoc C# (CSharp) Method

StLoc() public static method

Emits the IL to pop (OpCodes.Stloc) the top of the stack into a local variable.
public static StLoc ( this g, LocalBuilder local ) : void
g this This object.
local System.Reflection.Emit.LocalBuilder The local variable to pop.
return void
        public static void StLoc( this ILGenerator g, LocalBuilder local )
        {
            int i = local.LocalIndex;
            if( i == 0 ) g.Emit( OpCodes.Stloc_0 );
            else if( i == 1 ) g.Emit( OpCodes.Stloc_1 );
            else if( i == 2 ) g.Emit( OpCodes.Stloc_2 );
            else if( i == 3 ) g.Emit( OpCodes.Stloc_3 );
            else if( i < 255 ) g.Emit( OpCodes.Stloc_S, (byte)i );
            else g.Emit( OpCodes.Stloc, (short)i );
        }