private void CatchBreakException(CodeGenContext context, int result, PERWAPI.CILLabel endLabel) { // catch (Exception exception) int exception = context.StoreInTemp("exception", Runtime.BreakExceptionRef, location); PERWAPI.CILLabel reThrowLabel = context.NewLabel(); // if (exception.scope != current_frame) goto reThrowLabel; context.ldloc(0); context.ldloc(exception); context.ldfld(Runtime.BreakException.scope); context.bne( reThrowLabel); // result = exception.return_value; context.ldloc(exception); context.ldfld(Runtime.BreakException.return_value); context.stloc(result); // goto endLabel; context.Goto(endLabel); // reThrowLabel: context.CodeLabel(reThrowLabel); // throw exception; context.ldloc(exception); context.throwOp(); context.ReleaseLocal(exception, true); }
internal void CatchReturnException(CodeGenContext context, PERWAPI.TryBlock tryBlock) { // catch (Ruby.ReturnException exception) { ... } context.StartBlock(Clause.Catch); { PERWAPI.CILLabel falseLabel = context.NewLabel(); int exception = context.StoreInTemp("exception", Runtime.ReturnExceptionRef, location); // if (exception.scope == thisframe) context.ldloc(exception); context.ldfld(Runtime.ReturnException.scope); context.ldloc(0); context.bne(falseLabel); // returnTemp = exception.return_value; context.ldloc(exception); context.ldfld(Runtime.ReturnException.return_value); context.stloc(returnTemp); context.Goto(context.labels.Return); // falseLabel: context.CodeLabel(falseLabel); // throw exception context.rethrow(); context.ReleaseLocal(exception, true); } context.EndCatchBlock(Runtime.ReturnExceptionRef, tryBlock); }
private void CatchRetryException(CodeGenContext context, PERWAPI.CILLabel retryLabel) { // catch (Exception exception) int exception = context.StoreInTemp("exception", Runtime.RetryExceptionRef, location); PERWAPI.CILLabel reThrowLabel = context.NewLabel(); // if (exception.scope != current_frame) goto reThrowLabel; context.ldloc(0); context.ldloc(exception); context.ldfld(Runtime.RetryException.scope); context.bne( reThrowLabel); // goto retryLabel context.Goto(retryLabel); // reThrowLabel: context.CodeLabel(reThrowLabel); // throw exception; context.ldloc(exception); context.throwOp(); context.ReleaseLocal(exception, true); }