public static IRReturnJump create(DynamicScope scopeToReturnFrom, Object rv) { return new IRReturnJump(scopeToReturnFrom, rv); }
public static IRubyObject initiateNonLocalReturn(ThreadContext context, DynamicScope dynScope, Block block, IRubyObject returnValue) { if (block != null && IRRuntimeHelpers.inLambda(block.type)) throw new IRWrappedLambdaReturnValue(returnValue); throw IRReturnJump.create(getContainingMethodOrLambdasDynamicScope(dynScope), returnValue); }
public static IRubyObject initiateNonLocalReturn(ThreadContext context, DynamicScope dynScope, Block block, IRubyObject returnValue) { if (block != null && IRRuntimeHelpers.inLambda(block.type)) throw new IRWrappedLambdaReturnValue(returnValue); throw IRReturnJump.create(getContainingMethodOrLambdasDynamicScope(dynScope), returnValue); }
public static void initiateNonLocalReturn(ThreadContext context, IRScope scope, IRMethod methodToReturnFrom, IRubyObject returnValue) { if (scope instanceof IRClosure) { if (methodToReturnFrom == null) { // SSS FIXME: As Tom correctly pointed out, this is not correct. The example that breaks this code is: // // jruby -X-CIR -e "Thread.new { Proc.new { return }.call }.join" // // This should report a LocalJumpError, not a ThreadError. // // The right fix would involve checking the closure to see who it is associated with. // If it is a thread-body, it would be a ThreadError. If not, it would be a local-jump-error // This requires having access to the block -- same requirement as in handleBreakJump. if (context.getThread() == context.runtime.getThreadService().getMainThread()) { throw IRException.RETURN_LocalJumpError.getException(context.runtime); } else { throw context.runtime.newThreadError("return can't jump across threads"); } } // Cannot return from the call that we have long since exited. if (!context.scopeExistsOnCallStack(methodToReturnFrom.getStaticScope())) { if (isDebug()) LOG.info("in scope: " + scope + ", raising unexpected return local jump error"); throw IRException.RETURN_LocalJumpError.getException(context.runtime); } } // methodtoReturnFrom will not be null for explicit returns from class/module/sclass bodies throw IRReturnJump.create(methodToReturnFrom, returnValue); }
public static IRReturnJump create(DynamicScope scopeToReturnFrom, Object rv) { return new IRReturnJump(scopeToReturnFrom, rv); }
public static void initiateNonLocalReturn(ThreadContext context, IRScope scope, IRMethod methodToReturnFrom, IRubyObject returnValue) { if (scope instanceof IRClosure) { if (methodToReturnFrom == null) { // SSS FIXME: As Tom correctly pointed out, this is not correct. The example that breaks this code is: // // jruby -X-CIR -e "Thread.new { Proc.new { return }.call }.join" // // This should report a LocalJumpError, not a ThreadError. // // The right fix would involve checking the closure to see who it is associated with. // If it is a thread-body, it would be a ThreadError. If not, it would be a local-jump-error // This requires having access to the block -- same requirement as in handleBreakJump. if (context.getThread() == context.runtime.getThreadService().getMainThread()) { throw IRException.RETURN_LocalJumpError.getException(context.runtime); } else { throw context.runtime.newThreadError("return can't jump across threads"); } } // Cannot return from the call that we have long since exited. if (!context.scopeExistsOnCallStack(methodToReturnFrom.getStaticScope())) { if (isDebug()) LOG.info("in scope: " + scope + ", raising unexpected return local jump error"); throw IRException.RETURN_LocalJumpError.getException(context.runtime); } } // methodtoReturnFrom will not be null for explicit returns from class/module/sclass bodies throw IRReturnJump.create(methodToReturnFrom, returnValue); }
public static IRReturnJump create(IRMethod m, Object rv) { IRReturnJump rj; Reference<IRReturnJump> rjRef = threadLocalRJ.get(); if (rjRef != null) { rj = rjRef.get(); } else { rj = new IRReturnJump(); threadLocalRJ.set(new SoftReference<IRReturnJump>(rj)); } rj.methodToReturnFrom = m; rj.returnValue = rv; return rj; } }
public static IRReturnJump create(IRMethod m, Object rv) { IRReturnJump rj; Reference<IRReturnJump> rjRef = threadLocalRJ.get(); if (rjRef != null) { rj = rjRef.get(); } else { rj = new IRReturnJump(); threadLocalRJ.set(new SoftReference<IRReturnJump>(rj)); } rj.methodToReturnFrom = m; rj.returnValue = rv; return rj; } }