本文整理汇总了C#中MsgPack.Serialization.Reflection.TracingILGenerator.EmitConv_I4方法的典型用法代码示例。如果您正苦于以下问题:C# TracingILGenerator.EmitConv_I4方法的具体用法?C# TracingILGenerator.EmitConv_I4怎么用?C# TracingILGenerator.EmitConv_I4使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MsgPack.Serialization.Reflection.TracingILGenerator
的用法示例。
在下文中一共展示了TracingILGenerator.EmitConv_I4方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitGetUnpackerItemsCountAsInt32
/// <summary>
/// Emits gets <see cref="Unpacker.ItemsCount"/> with exception handling.
/// Note that final state is the value is pushed top of the evaluation stack.
/// </summary>
/// <param name="il">IL generator.</param>
/// <param name="unpackerArgumentIndex">Argument index of the unpacker.</param>
/// <param name="localHolder">The <see cref="LocalVariableHolder"/> which holds shared local variable information.</param>
public static void EmitGetUnpackerItemsCountAsInt32( TracingILGenerator il, int unpackerArgumentIndex, LocalVariableHolder localHolder )
{
Contract.Requires( il != null );
Contract.Requires( unpackerArgumentIndex >= 0 );
/*
* long rawItemsCount;
* try
* {
* rawItemsCount = unpacker.ItemsCount;
* }
* catch ( InvalidOperationException ex )
* {
* throw SerializationExceptions.NewIsIncorrectStream( ex );
* }
*
* if( rawItemsCount > Int32.MaxValue )
* {
* throw SerializationException.NewIsTooLargeCollection();
* }
*
* ... unchecked( ( int )rawItemsCount );
*/
il.EmitAnyLdloca( localHolder.RawItemsCount );
il.EmitInitobj( typeof( long ) );
il.BeginExceptionBlock();
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.ItemsCount );
il.EmitAnyStloc( localHolder.RawItemsCount );
il.BeginCatchBlock( typeof( InvalidOperationException ) );
il.EmitAnyCall( SerializationExceptions.NewIsIncorrectStreamMethod );
il.EmitThrow();
il.EndExceptionBlock();
il.EmitAnyLdloc( localHolder.RawItemsCount );
il.EmitLdc_I8( Int32.MaxValue );
var endIf = il.DefineLabel();
il.EmitBle_S( endIf );
il.EmitAnyCall( SerializationExceptions.NewIsTooLargeCollectionMethod );
il.EmitThrow();
il.MarkLabel( endIf );
il.EmitAnyLdloc( localHolder.RawItemsCount );
il.EmitConv_I4();
}