Mast/Common/DynamicCalls.cs
/// <summary>Emits code to save an integer to the evaluation stack.</summary>
/// <param name="ilGeneartor">The MSIL generator.</param>
/// <param name="value">The value to push.</param>
Emits code to save an integer to the evaluation stack.
Emits code to save an integer to the evaluation stack .
private static void EmitFastInt(ILGenerator ilGenerator, int value)
        {
            switch (value)
            {
                case -1:
                    ilGenerator.Emit(OpCodes.Ldc_I4_M1);
                    return;
                case 0:
                    ilGenerator.Emit(OpCodes.Ldc_I4_0);
                    return;
                case 1:
                    ilGenerator.Emit(OpCodes.Ldc_I4_1);
                    return;
                case 2:
                    ilGenerator.Emit(OpCodes.Ldc_I4_2);
                    return;
                case 3:
                    ilGenerator.Emit(OpCodes.Ldc_I4_3);
                    return;
                case 4:
                    ilGenerator.Emit(OpCodes.Ldc_I4_4);
                    return;
                case 5:
                    ilGenerator.Emit(OpCodes.Ldc_I4_5);
                    return;
                case 6:
                    ilGenerator.Emit(OpCodes.Ldc_I4_6);
                    return;
                case 7:
                    ilGenerator.Emit(OpCodes.Ldc_I4_7);
                    return;
                case 8:
                    ilGenerator.Emit(OpCodes.Ldc_I4_8);
                    return;
            }
            if (value > -129 && value < 128)
            {
                ilGenerator.Emit(OpCodes.Ldc_I4_S, (SByte)value);
            }
            else
            {
                ilGenerator.Emit(OpCodes.Ldc_I4, value);
            }
        }
private static void EmitFastInt ( ILGenerator ilGenerator , int value ) { switch ( value ) { case - 1 : ilGenerator . Emit ( OpCodes . Ldc_I4_M1 ) ; return ; case 0 : ilGenerator . Emit ( OpCodes . Ldc_I4_0 ) ; return ; case 1 : ilGenerator . Emit ( OpCodes . Ldc_I4_1 ) ; return ; case 2 : ilGenerator . Emit ( OpCodes . Ldc_I4_2 ) ; return ; case 3 : ilGenerator . Emit ( OpCodes . Ldc_I4_3 ) ; return ; case 4 : ilGenerator . Emit ( OpCodes . Ldc_I4_4 ) ; return ; case 5 : ilGenerator . Emit ( OpCodes . Ldc_I4_5 ) ; return ; case 6 : ilGenerator . Emit ( OpCodes . Ldc_I4_6 ) ; return ; case 7 : ilGenerator . Emit ( OpCodes . Ldc_I4_7 ) ; return ; case 8 : ilGenerator . Emit ( OpCodes . Ldc_I4_8 ) ; return ; } if ( value > - 129 && value < 128 ) { ilGenerator . Emit ( OpCodes . Ldc_I4_S , ( SByte ) value ) ; } else { ilGenerator . Emit ( OpCodes . Ldc_I4 , value ) ; } }
Emits code to save an integer to the evaluation stack.
Emits code to save an integer to the evaluation stack .
// for small integers, emit the proper opcode // for bigger values emit the short or long opcode
ilGenerator
ILGenerator
value
int
The value to push.
The value to push .
ilGeneartor
The MSIL generator.
The MSIL generator .