本文整理汇总了C#中Mono.CSharp.EmitContext.BeginFinallyBlock方法的典型用法代码示例。如果您正苦于以下问题:C# EmitContext.BeginFinallyBlock方法的具体用法?C# EmitContext.BeginFinallyBlock怎么用?C# EmitContext.BeginFinallyBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.EmitContext
的用法示例。
在下文中一共展示了EmitContext.BeginFinallyBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitForDispose
public override void EmitForDispose (EmitContext ec, Iterator iterator, Label end, bool have_dispatcher)
{
if (emitted_dispose)
return;
emitted_dispose = true;
Label end_of_try = ec.DefineLabel ();
// Ensure that the only way we can get into this code is through a dispatcher
if (have_dispatcher)
ec.Emit (OpCodes.Br, end);
ec.BeginExceptionBlock ();
ec.MarkLabel (dispose_try_block);
Label [] labels = null;
for (int i = 0; i < resume_points.Count; ++i) {
ResumableStatement s = (ResumableStatement) resume_points [i];
Label ret = s.PrepareForDispose (ec, end_of_try);
if (ret.Equals (end_of_try) && labels == null)
continue;
if (labels == null) {
labels = new Label [resume_points.Count];
for (int j = 0; j < i; ++j)
labels [j] = end_of_try;
}
labels [i] = ret;
}
if (labels != null) {
int j;
for (j = 1; j < labels.Length; ++j)
if (!labels [0].Equals (labels [j]))
break;
bool emit_dispatcher = j < labels.Length;
if (emit_dispatcher) {
//SymbolWriter.StartIteratorDispatcher (ec.ig);
ec.Emit (OpCodes.Ldloc, iterator.CurrentPC);
ec.EmitInt (first_resume_pc);
ec.Emit (OpCodes.Sub);
ec.Emit (OpCodes.Switch, labels);
//SymbolWriter.EndIteratorDispatcher (ec.ig);
}
foreach (ResumableStatement s in resume_points)
s.EmitForDispose (ec, iterator, end_of_try, emit_dispatcher);
}
ec.MarkLabel (end_of_try);
ec.BeginFinallyBlock ();
EmitFinallyBody (ec);
ec.EndExceptionBlock ();
}
示例2: DoEmit
protected sealed override void DoEmit (EmitContext ec)
{
EmitPreTryBody (ec);
if (resume_points != null) {
ec.EmitInt ((int) Iterator.State.Running);
ec.Emit (OpCodes.Stloc, iter.CurrentPC);
}
ec.BeginExceptionBlock ();
if (resume_points != null) {
ec.MarkLabel (resume_point);
// For normal control flow, we want to fall-through the Switch
// So, we use CurrentPC rather than the $PC field, and initialize it to an outside value above
ec.Emit (OpCodes.Ldloc, iter.CurrentPC);
ec.EmitInt (first_resume_pc);
ec.Emit (OpCodes.Sub);
Label [] labels = new Label [resume_points.Count];
for (int i = 0; i < resume_points.Count; ++i)
labels [i] = resume_points [i].PrepareForEmit (ec);
ec.Emit (OpCodes.Switch, labels);
}
EmitTryBody (ec);
ec.BeginFinallyBlock ();
Label start_finally = ec.DefineLabel ();
if (resume_points != null) {
ec.Emit (OpCodes.Ldloc, iter.SkipFinally);
ec.Emit (OpCodes.Brfalse_S, start_finally);
ec.Emit (OpCodes.Endfinally);
}
ec.MarkLabel (start_finally);
EmitFinallyBody (ec);
ec.EndExceptionBlock ();
}