本文整理汇总了C#中CodeGen.EmitTraceBackTryBlockStart方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitTraceBackTryBlockStart方法的具体用法?C# CodeGen.EmitTraceBackTryBlockStart怎么用?C# CodeGen.EmitTraceBackTryBlockStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.EmitTraceBackTryBlockStart方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
//.........这里部分代码省略.........
cg.PushExceptionBlock(Targets.TargetBlockType.Try, flowControlVar, isTryYielded);
cg.BeginExceptionBlock();
// if catch yielded, rethow the storedException to be handled by Catch block
if (IsBlockYieldable(catchYieldTargets)) {
Label testFinally = cg.DefineLabel();
isCatchYielded.EmitGet(cg);
cg.EmitUnbox(typeof(bool));
cg.Emit(OpCodes.Brfalse, testFinally);
storedException.EmitGet(cg);
cg.EmitCall(typeof(Ops), "Raise", new Type[] { typeof(object) });
cg.MarkLabel(testFinally);
}
// if Finally yielded, Branch to the end of Try block
Label endOfTry = cg.DefineLabel();
EmitOnYieldBranchToLabel(finallyYieldTargets, isFinallyYielded, endOfTry, cg);
Label beginElseBlock = cg.DefineLabel();
if (IsBlockYieldable(elseYieldTargets)) {
// isElseYielded ?
Debug.Assert(isElseYielded != null);
isElseYielded.EmitGet(cg);
cg.EmitUnbox(typeof(bool));
cg.Emit(OpCodes.Brtrue, beginElseBlock);
}
EmitYieldDispatch(tryYieldTargets, isTryYielded, tryChoiceVar, cg);
// if finally block presents, but no exception handler, we add try-fault
// to update traceback; otherwise, we update the traceback inside exception handler.
if (finallyStmt != null && handlers == null) {
Slot dummySlot = cg.GetLocalTmp(typeof(object));
cg.EmitTraceBackTryBlockStart(dummySlot);
body.Emit(cg);
cg.FreeLocalTmp(dummySlot);
cg.EmitTraceBackFaultBlock();
} else {
body.Emit(cg);
}
if (elseStmt != null) {
if (IsBlockYieldable(elseYieldTargets)) {
cg.MarkLabel(beginElseBlock);
}
cg.PopTargets(Targets.TargetBlockType.Try);
cg.PushExceptionBlock(Targets.TargetBlockType.Else, flowControlVar, isElseYielded);
cg.EmitInt(1);
isElseBlock.EmitSet(cg);
EmitYieldDispatch(elseYieldTargets, isElseYielded, elseChoiceVar, cg);
elseStmt.Emit(cg);
cg.PopTargets(Targets.TargetBlockType.Else);
cg.PushExceptionBlock(Targets.TargetBlockType.Try, flowControlVar, isTryYielded);
}
cg.MarkLabel(endOfTry);
// get the exception if there is a yield / return in finally
if (IsBlockYieldable(finallyYieldTargets) || returnInFinally) {
示例2: EmitFunctionImplementation
/// <summary>
/// Emits the raw function implementation into a method body. Requires both a
/// code gen for the method and for any initialization that might be required
/// before the method is run (a module init or type cctor). True if the method
/// requires context, false if it doesn't.
/// </summary>
/// <param name="cg"></param>
/// <param name="icg"></param>
/// <param name="context"></param>
internal void EmitFunctionImplementation(CodeGen methodCodeGen, CodeGen initCodeGen)
{
if (EmitLocalDictionary) {
PromoteLocalsToEnvironment();
}
// emit the actual body
if (yieldCount > 0) {
EmitGeneratorBody(methodCodeGen, initCodeGen);
} else {
Slot dummySlot = methodCodeGen.GetLocalTmp(typeof(object));
methodCodeGen.EmitTraceBackTryBlockStart(dummySlot);
methodCodeGen.FuncOrClassName = name.ToString();
methodCodeGen.EmitSetTraceBackUpdateStatus(false);
EmitFunctionBody(methodCodeGen, initCodeGen);
methodCodeGen.FreeLocalTmp(dummySlot);
methodCodeGen.EmitTraceBackFaultBlock();
}
}