本文整理汇总了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 );
}