本文整理汇总了C#中MsgPack.Serialization.Reflection.TracingILGenerator.EmitLdc_I4_1方法的典型用法代码示例。如果您正苦于以下问题:C# TracingILGenerator.EmitLdc_I4_1方法的具体用法?C# TracingILGenerator.EmitLdc_I4_1怎么用?C# TracingILGenerator.EmitLdc_I4_1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MsgPack.Serialization.Reflection.TracingILGenerator
的用法示例。
在下文中一共展示了TracingILGenerator.EmitLdc_I4_1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitFor
/// <summary>
/// Emits 'for' statement on current IL stream.
/// </summary>
/// <param name="il">IL generator to be emitted to.</param>
/// <param name="count">'count' local variable which is <see cref="Int32"/> type and holds maximum loop count.</param>
/// <param name="bodyEmitter">Delegate to emit for statement body.</param>
public static void EmitFor( TracingILGenerator il, LocalBuilder count, Action<TracingILGenerator, LocalBuilder> bodyEmitter )
{
Contract.Requires( il != null );
Contract.Requires( count != null );
Contract.Requires( bodyEmitter != null );
var i = il.DeclareLocal( typeof( int ), "i" );
il.EmitLdc_I4_0();
il.EmitAnyStloc( i );
var forCond = il.DefineLabel( "FOR_COND" );
il.EmitBr( forCond );
var body = il.DefineLabel( "BODY" );
il.MarkLabel( body );
bodyEmitter( il, i );
// increment
il.EmitAnyLdloc( i );
il.EmitLdc_I4_1();
il.EmitAdd();
il.EmitAnyStloc( i );
// cond
il.MarkLabel( forCond );
il.EmitAnyLdloc( i );
il.EmitAnyLdloc( count );
il.EmitBlt( body );
}
示例2: EmitDeserializeValue
//.........这里部分代码省略.........
* goto END_OF_DESERIALIZATION;
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.Data );
var data = il.DeclareLocal( typeof( MessagePackObject? ), "data" );
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = il.DeclareLocal( typeof( MessagePackObject ), "dataValue" );
il.EmitAnyStloc( dataValue );
il.EmitAnyLdloca( dataValue );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
il.EmitBrtrue( endOfDeserialization );
break;
}
case NilImplication.Prohibit:
{
/*
* if( unpacker.Data.Value.IsNil )
* {
* throw SerializationEceptions.NewProhibitNullException( "..." );
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.Data );
var data = il.DeclareLocal( typeof( MessagePackObject? ), "data" );
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = il.DeclareLocal( typeof( MessagePackObject ), "dataValue" );
il.EmitAnyStloc( dataValue );
il.EmitAnyLdloca( dataValue );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
var endIf0 = il.DefineLabel( "END_IF0" );
il.EmitBrfalse_S( endIf0 );
il.EmitLdstr( memberName );
il.EmitAnyCall( SerializationExceptions.NewNullIsProhibitedMethod );
il.EmitThrow();
il.MarkLabel( endIf0 );
break;
}
}
}
/*
*
* if( !unpacker.IsArrayHeader && !unpacker.IsMapHeader )
* {
* valueN = GET_SERIALIZER.UnpackFrom( unpacker );
* }
* else
* {
* using( var subtreeUnpacker = unpacker.ReadSubtree )
* {
* valueN = GET_SERIALIZER.UnpackFrom( unpacker );
* }
* }
*
* isValueNUnpacked = true;
* END_OF_DESERIALIZATION:
*/
var then = il.DefineLabel( "THEN" );
var endIf = il.DefineLabel( "END_IF" );
var serializerGetter = emitter.RegisterSerializer( value.LocalType );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsArrayHeader );
il.EmitBrtrue_S( then );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsMapHeader );
il.EmitBrtrue_S( then );
// else
serializerGetter( il, 0 );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
il.EmitBr_S( endIf );
// then
var subtreeUnpacker = il.DeclareLocal( typeof( Unpacker ), "subtreeUnpacker" );
il.MarkLabel( then );
EmitUnpackerBeginReadSubtree( il, unpackerArgumentIndex, subtreeUnpacker );
serializerGetter( il, 0 );
il.EmitAnyLdloc( subtreeUnpacker );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
EmitUnpackerEndReadSubtree( il, subtreeUnpacker );
il.MarkLabel( endIf );
if ( isUnpacked != null )
{
il.EmitLdc_I4_1();
il.EmitAnyStloc( isUnpacked );
}
il.MarkLabel( endOfDeserialization );
}