本文整理汇总了C#中Mono.CSharp.Block.Emit方法的典型用法代码示例。如果您正苦于以下问题:C# Block.Emit方法的具体用法?C# Block.Emit怎么用?C# Block.Emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.Block
的用法示例。
在下文中一共展示了Block.Emit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitMoveNext_NoResumePoints
void EmitMoveNext_NoResumePoints(EmitContext ec, Block original_block)
{
ec.Emit (OpCodes.Ldarg_0);
ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec);
ec.Emit (OpCodes.Ldarg_0);
ec.EmitInt ((int) State.After);
ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);
// We only care if the PC is zero (start executing) or non-zero (don't do anything)
ec.Emit (OpCodes.Brtrue, move_next_error);
SymbolWriter.StartIteratorBody (ec);
original_block.Emit (ec);
SymbolWriter.EndIteratorBody (ec);
ec.MarkLabel (move_next_error);
ec.Emit (OpCodes.Ldc_I4_0);
ec.Emit (OpCodes.Ret);
}
示例2: EmitMoveNext
internal void EmitMoveNext(EmitContext ec, Block original_block)
{
move_next_ok = ec.DefineLabel ();
move_next_error = ec.DefineLabel ();
if (resume_points == null) {
EmitMoveNext_NoResumePoints (ec, original_block);
return;
}
current_pc = ec.GetTemporaryLocal (TypeManager.uint32_type);
ec.Emit (OpCodes.Ldarg_0);
ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec);
ec.Emit (OpCodes.Stloc, current_pc);
// We're actually in state 'running', but this is as good a PC value as any if there's an abnormal exit
ec.Emit (OpCodes.Ldarg_0);
ec.EmitInt ((int) State.After);
ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);
Label [] labels = new Label [1 + resume_points.Count];
labels [0] = ec.DefineLabel ();
bool need_skip_finally = false;
for (int i = 0; i < resume_points.Count; ++i) {
ResumableStatement s = resume_points [i];
need_skip_finally |= s is ExceptionStatement;
labels [i+1] = s.PrepareForEmit (ec);
}
if (need_skip_finally) {
skip_finally = ec.GetTemporaryLocal (TypeManager.bool_type);
ec.Emit (OpCodes.Ldc_I4_0);
ec.Emit (OpCodes.Stloc, skip_finally);
}
SymbolWriter.StartIteratorDispatcher (ec);
ec.Emit (OpCodes.Ldloc, current_pc);
ec.Emit (OpCodes.Switch, labels);
ec.Emit (OpCodes.Br, move_next_error);
SymbolWriter.EndIteratorDispatcher (ec);
ec.MarkLabel (labels [0]);
SymbolWriter.StartIteratorBody (ec);
original_block.Emit (ec);
SymbolWriter.EndIteratorBody (ec);
SymbolWriter.StartIteratorDispatcher (ec);
ec.Emit (OpCodes.Ldarg_0);
ec.EmitInt ((int) State.After);
ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);
ec.MarkLabel (move_next_error);
ec.EmitInt (0);
ec.Emit (OpCodes.Ret);
ec.MarkLabel (move_next_ok);
ec.Emit (OpCodes.Ldc_I4_1);
ec.Emit (OpCodes.Ret);
SymbolWriter.EndIteratorDispatcher (ec);
}