本文整理匯總了C#中MsgPack.Serialization.Reflection.TracingILGenerator.EmitAdd方法的典型用法代碼示例。如果您正苦於以下問題:C# TracingILGenerator.EmitAdd方法的具體用法?C# TracingILGenerator.EmitAdd怎麽用?C# TracingILGenerator.EmitAdd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MsgPack.Serialization.Reflection.TracingILGenerator
的用法示例。
在下文中一共展示了TracingILGenerator.EmitAdd方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 );
}