本文整理汇总了C#中CodeGenContext.EndTryBlock方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenContext.EndTryBlock方法的具体用法?C# CodeGenContext.EndTryBlock怎么用?C# CodeGenContext.EndTryBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenContext
的用法示例。
在下文中一共展示了CodeGenContext.EndTryBlock方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenCall
internal void GenCall(CodeGenContext context)
{
int result = context.CreateLocal("result", PrimitiveType.Object);
PERWAPI.CILLabel endLabel = context.NewLabel();
PERWAPI.CILLabel retryLabel = context.NewLabel();
context.CodeLabel(retryLabel);
context.StartBlock(Clause.Try);
{
// object result = Call(...)
GenCall0(context);
context.stloc(result);
context.Goto(endLabel);
}
PERWAPI.TryBlock tryBlock = context.EndTryBlock();
context.StartBlock(Clause.Catch);
{
CatchBreakException(context, result, endLabel);
}
context.EndCatchBlock(Runtime.BreakExceptionRef, tryBlock);
context.StartBlock(Clause.Catch);
{
CatchRetryException(context, retryLabel);
}
context.EndCatchBlock(Runtime.RetryExceptionRef, tryBlock);
context.CodeLabel(endLabel);
context.ldloc(result);
context.ReleaseLocal(result, true);
}
示例2: GenCode0
internal override void GenCode0(CodeGenContext context)
{
PERWAPI.CILLabel finalLabel = context.NewLabel();
int RescueTemp = context.CreateLocal("rescueTemp", PERWAPI.PrimitiveType.Object);
context.ldnull();
context.stloc(RescueTemp);
if (ensure != null)
{
context.StartBlock(Clause.Try); // outer try block with finally
context.StartBlock(Clause.Try); // inner try block with catch
}
GenInnerBlock(context, RescueTemp);
if (ensure != null)
{
context.Goto(finalLabel);
PERWAPI.TryBlock innerTry = context.EndTryBlock();
context.StartBlock(Clause.Catch);
GenRescue(context, null, 0, null);
context.EndCatchBlock(Runtime.SystemExceptionRef, innerTry);
PERWAPI.TryBlock outerTry = context.EndTryBlock();
// Fixme: reset labels to prevent branches out of finally block.
context.StartBlock(Clause.Finally);
ensure.GenCode(context);
if (context.Reachable())
context.pop();
context.endfinally();
context.EndFinallyBlock(outerTry);
context.CodeLabel(finalLabel);
context.newEndPoint(location);
}
context.ldloc(RescueTemp);
context.ReleaseLocal(RescueTemp, true);
}
示例3: AddScopeBody
internal void AddScopeBody(CodeGenContext context)
{
returnTemp = context.CreateLocal("returnTemp", PrimitiveType.Object);
context.labels = new Labels();
context.labels.Redo = context.NewLabel();
context.labels.Return = context.NewLabel();
// try { ... }
context.StartBlock(Clause.Try);
{
if (BEGIN != null)
BEGIN.GenCode(context);
context.CodeLabel(context.labels.Redo);
if (body != null)
{
body.GenCode(context);
if (context.Reachable())
context.stloc(returnTemp);
}
context.Goto(context.labels.Return);
}
PERWAPI.TryBlock tryBlock = context.EndTryBlock();
CatchReturnException(context, tryBlock);
// ReturnLabel:
// return returnTemp;
context.CodeLabel(context.labels.Return);
context.newEndPoint(location);
if (context.Method.GetRetType() != PERWAPI.PrimitiveType.Void)
context.ldloc(returnTemp);
context.ret();
context.ReleaseLocal(returnTemp, true);
}
示例4: Defined
internal override void Defined(CodeGenContext context)
{
if (qualified)
if (scope != null)
{
// object result;
int result = context.CreateLocal("result", PrimitiveType.Object);
PERWAPI.CILLabel endLabel = context.NewLabel();
// try {
context.StartBlock(Clause.Try);
{
// result = Eval.const_defined(scope, vid, caller);
scope.GenCode(context);
context.ldstr(vid.ToString());
context.ldloc(0);
context.call(Runtime.Eval.const_defined);
context.stloc(result);
context.leave(endLabel);
}
TryBlock block = context.EndTryBlock();
// catch (System.Exception) {
context.StartBlock(Clause.Catch);
{
// result = null;
context.ldnull();
context.stloc(result);
context.leave(endLabel);
}
context.EndCatchBlock(Runtime.SystemExceptionRef, block);
context.CodeLabel(endLabel);
context.ldloc(result);
context.ReleaseLocal(result, true);
}
else
{
context.ldsfld(Ruby.Compiler.Runtime.Init.rb_cObject);
context.ldstr(vid.ToString());
context.ldloc(0);
context.call(Runtime.Eval.const_defined);
}
else
{
context.ruby_cbase(parent_scope);
context.ldstr(vid.ToString());
context.ldloc(0);
context.call(Runtime.Eval.const_defined);
}
}
示例5: GenInnerBlock
private void GenInnerBlock(CodeGenContext context, int RescueTemp)
{
PERWAPI.CILLabel elseLabel = context.NewLabel();
Labels catchLabels = new Labels();
catchLabels.Break = context.labels.Break;
catchLabels.Next = context.labels.Next;
catchLabels.Redo = context.labels.Redo;
catchLabels.Return = context.labels.Return;
catchLabels.Retry = context.NewLabel();
context.CodeLabel(catchLabels.Retry);
context.StartBlock(Clause.Try);
{
if (body != null)
body.GenCode(context);
else
context.ldnull();
if (context.Reachable())
{
context.stloc(RescueTemp);
context.Goto(elseLabel);
}
}
PERWAPI.TryBlock innerTry = context.EndTryBlock();
PERWAPI.CILLabel endLabel = context.NewLabel();
if (rescue != null)
{
context.StartBlock(Clause.Catch);
{
Labels original = context.labels;
context.labels = catchLabels;
GenRescue(context, endLabel, RescueTemp, rescue);
context.labels = original;
}
context.EndCatchBlock(Runtime.SystemExceptionRef, innerTry);
}
context.CodeLabel(elseLabel);
{
if (_else != null)
{
_else.GenCode(context);
if (context.Reachable())
context.stloc(RescueTemp);
}
}
context.CodeLabel(endLabel);
}