private static IRubyObject rbThrowInternal(ThreadContext context, IRubyObject tag, IRubyObject arg) { final Ruby runtime = context.runtime; runtime.getGlobalVariables().set("$!", context.nil); RubyContinuation.Continuation continuation = context.getActiveCatch(tag); if (continuation != null) { continuation.args = arg == null ? IRubyObject.NULL_ARRAY : new IRubyObject[] { arg }; throw continuation; } // No catch active for this throw IRubyObject value = arg == null ? context.nil : arg; throw uncaughtThrow(runtime, tag, value, RubyString.newStringShared(runtime, uncaught_throw_p)); }
private static IRubyObject rbThrowInternal(ThreadContext context, IRubyObject tag, IRubyObject arg) { final Ruby runtime = context.runtime; runtime.getGlobalVariables().set("$!", context.nil); RubyContinuation.Continuation continuation = context.getActiveCatch(tag); if (continuation != null) { continuation.args = arg == null ? IRubyObject.NULL_ARRAY : new IRubyObject[] { arg }; throw continuation; } // No catch active for this throw IRubyObject value = arg == null ? context.nil : arg; throw uncaughtThrow(runtime, tag, value, RubyString.newStringShared(runtime, uncaught_throw_p)); }
/** * Find the active Continuation for the given tag. Must be called with an * interned string. * * @param tag The interned string to search for * @return The continuation associated with this tag */ public Continuation getActiveCatch(Object tag) { for (int i = catchIndex; i >= 0; i--) { Continuation c = catchStack[i]; if (runtime.is1_9()) { if (c.tag == tag) return c; } else { if (c.tag.equals(tag)) return c; } } // if this is a fiber, search prev for tag ThreadFiber fiber = getFiber(); ThreadFiber prev; if (fiber != null && (prev = fiber.getData().getPrev()) != null) { return prev.getThread().getContext().getActiveCatch(tag); } return null; }
/** * Find the active Continuation for the given tag. Must be called with an * interned string. * * @param tag The interned string to search for * @return The continuation associated with this tag */ public Continuation getActiveCatch(Object tag) { for (int i = catchIndex; i >= 0; i--) { Continuation c = catchStack[i]; if (c.tag == tag) return c; } // if this is a fiber, search prev for tag ThreadFiber fiber = getFiber(); ThreadFiber prev; if (fiber != null && (prev = fiber.getData().getPrev()) != null) { return prev.getThread().getContext().getActiveCatch(tag); } return null; }
/** * Find the active Continuation for the given tag. Must be called with an * interned string. * * @param tag The interned string to search for * @return The continuation associated with this tag */ public Continuation getActiveCatch(Object tag) { for (int i = catchIndex; i >= 0; i--) { Continuation c = catchStack[i]; if (c.tag == tag) return c; } // if this is a fiber, search prev for tag ThreadFiber fiber = getFiber(); ThreadFiber prev; if (fiber != null && (prev = fiber.getData().getPrev()) != null) { return prev.getThread().getContext().getActiveCatch(tag); } return null; }
runtime.getGlobalVariables().set("$!", runtime.getNil()); RubyContinuation.Continuation continuation = context.getActiveCatch(tag);
runtime.getGlobalVariables().set("$!", runtime.getNil()); RubyContinuation.Continuation continuation = context.getActiveCatch(tag);