public static IRBreakJump create(DynamicScope scopeToReturnTo, IRubyObject rv, boolean breakInEval) { return new IRBreakJump(scopeToReturnTo, rv, breakInEval); } }
public static IRubyObject initiateBreak(ThreadContext context, IRScope scope, int scopeIdToReturnTo, IRubyObject breakValue, Block.Type blockType) throws RuntimeException { if (inLambda(blockType)) { // Ensures would already have been run since the IR builder makes // sure that ensure code has run before we hit the break. Treat // the break as a regular return from the closure. return breakValue; } else { if (!(scope instanceof IRClosure)) { // Error -- breaks can only be initiated in closures throw IRException.BREAK_LocalJumpError.getException(context.runtime); } IRBreakJump bj = IRBreakJump.create(scopeIdToReturnTo, breakValue); if (scope instanceof IREvalScript) { // If we are in an eval, record it so we can account for it bj.breakInEval = true; } // Start the process of breaking through the intermediate scopes throw bj; } }
public static IRubyObject initiateBreak(ThreadContext context, IRScope scope, int scopeIdToReturnTo, IRubyObject breakValue, Block.Type blockType) throws RuntimeException { if (inLambda(blockType)) { // Ensures would already have been run since the IR builder makes // sure that ensure code has run before we hit the break. Treat // the break as a regular return from the closure. return breakValue; } else { if (!(scope instanceof IRClosure)) { // Error -- breaks can only be initiated in closures throw IRException.BREAK_LocalJumpError.getException(context.runtime); } IRBreakJump bj = IRBreakJump.create(scopeIdToReturnTo, breakValue); if (scope instanceof IREvalScript) { // If we are in an eval, record it so we can account for it bj.breakInEval = true; } // Start the process of breaking through the intermediate scopes throw bj; } }
public static IRBreakJump create(DynamicScope scopeToReturnTo, IRubyObject rv, boolean breakInEval) { return new IRBreakJump(scopeToReturnTo, rv, breakInEval); } }
public static IRubyObject initiateBreak(ThreadContext context, DynamicScope dynScope, IRubyObject breakValue, Block block) throws RuntimeException { // Wrap the return value in an exception object and push it through the break exception // paths so that ensures are run, frames/scopes are popped from runtime stacks, etc. if (inLambda(block.type)) throw new IRWrappedLambdaReturnValue(breakValue); IRScopeType scopeType = ensureScopeIsClosure(context, dynScope); DynamicScope parentScope = dynScope.getParentScope(); if (block.isEscaped()) { throw context.runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, breakValue, "unexpected break"); } // Raise a break jump so we can bubble back down the stack to the appropriate place to break from. throw IRBreakJump.create(parentScope, breakValue, scopeType.isEval()); // weirdly evals are impld as closures...yes yes. }
@Deprecated public static IRBreakJump create(DynamicScope scopeToReturnTo, IRubyObject rv) { return new IRBreakJump(scopeToReturnTo, rv, false); }
public static IRubyObject initiateBreak(ThreadContext context, DynamicScope dynScope, IRubyObject breakValue, Block block) throws RuntimeException { // Wrap the return value in an exception object and push it through the break exception // paths so that ensures are run, frames/scopes are popped from runtime stacks, etc. if (inLambda(block.type)) throw new IRWrappedLambdaReturnValue(breakValue); IRScopeType scopeType = ensureScopeIsClosure(context, dynScope); DynamicScope parentScope = dynScope.getParentScope(); if (block.isEscaped()) { throw context.runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, breakValue, "unexpected break"); } // Raise a break jump so we can bubble back down the stack to the appropriate place to break from. throw IRBreakJump.create(parentScope, breakValue, scopeType.isEval()); // weirdly evals are impld as closures...yes yes. }
@Deprecated public static IRBreakJump create(DynamicScope scopeToReturnTo, IRubyObject rv) { return new IRBreakJump(scopeToReturnTo, rv, false); }
public static IRBreakJump create(int scopeIdToReturnTo, IRubyObject rv) { IRBreakJump bj; Reference<IRBreakJump> bjRef = threadLocalBJ.get(); if (bjRef != null) { bj = bjRef.get(); } else { bj = new IRBreakJump(); threadLocalBJ.set(new SoftReference<IRBreakJump>(bj)); } bj.scopeIdToReturnTo = scopeIdToReturnTo; bj.breakValue = rv; bj.caughtByLambda = false; bj.breakInEval = false; return bj; } }
public static IRBreakJump create(int scopeIdToReturnTo, IRubyObject rv) { IRBreakJump bj; Reference<IRBreakJump> bjRef = threadLocalBJ.get(); if (bjRef != null) { bj = bjRef.get(); } else { bj = new IRBreakJump(); threadLocalBJ.set(new SoftReference<IRBreakJump>(bj)); } bj.scopeIdToReturnTo = scopeIdToReturnTo; bj.breakValue = rv; bj.caughtByLambda = false; bj.breakInEval = false; return bj; } }