public Object next() { if (!iterator.hasNext()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return iterator.next(); }
public static void throwStopIteration(Object obj) { throw new JavaScriptException( NativeIterator.getStopIterationObject((Scriptable)obj), "", 0); }
private Object next(Context cx, Scriptable scope) { Boolean b = ScriptRuntime.enumNext(this.objectIterator); if (!b.booleanValue()) { // Out of values. Throw StopIteration. throw new JavaScriptException( NativeIterator.getStopIterationObject(scope), null, 0); } return ScriptRuntime.enumId(this.objectIterator, cx); }
private static Object thawGenerator(CallFrame frame, int stackTop, GeneratorState generatorState, int op) { // we are resuming execution frame.frozen = false; int sourceLine = getIndex(frame.idata.itsICode, frame.pc); frame.pc += 2; // skip line number data if (generatorState.operation == NativeGenerator.GENERATOR_THROW) { // processing a call to <generator>.throw(exception): must // act as if exception was thrown from resumption point return new JavaScriptException(generatorState.value, frame.idata.itsSourceFile, sourceLine); } if (generatorState.operation == NativeGenerator.GENERATOR_CLOSE) { return generatorState.value; } if (generatorState.operation != NativeGenerator.GENERATOR_SEND) throw Kit.codeBug(); if (op == Token.YIELD) frame.stack[stackTop] = generatorState.value; return Scriptable.NOT_FOUND; }
throw new JavaScriptException("Interpreter not present", filename, linep[0]);
/** * Encapsulates the given {@link DOMException} into a Rhino-compatible exception. * * @param exception the exception to encapsulate * @return the created exception */ protected RhinoException asJavaScriptException(final DOMException exception) { final Window w = getWindow(); exception.setPrototype(w.getPrototype(exception.getClass())); exception.setParentScope(w); // get current line and file name // this method can only be used in interpreted mode. If one day we choose to use compiled mode, // then we'll have to find an other way here. final String fileName; final int lineNumber; if (Context.getCurrentContext().getOptimizationLevel() == -1) { final int[] linep = new int[1]; final String sourceName = new Interpreter().getSourcePositionFromStack(Context.getCurrentContext(), linep); fileName = sourceName.replaceFirst("script in (.*) from .*", "$1"); lineNumber = linep[0]; } else { throw new Error("HtmlUnit not ready to run in compiled mode"); } exception.setLocation(fileName, lineNumber); return new JavaScriptException(exception, fileName, lineNumber); }
private RhinoException asJavaScriptException(final DOMException exception) { exception.setPrototype(getWindow().getPrototype(exception.getClass())); exception.setParentScope(getWindow()); // get current line and file name // this method can only be used in interpreted mode. If one day we choose to use compiled mode, // then we'll have to find an other way here. final String fileName; final int lineNumber; if (Context.getCurrentContext().getOptimizationLevel() == -1) { final int[] linep = new int[1]; final String sourceName = new Interpreter().getSourcePositionFromStack(Context.getCurrentContext(), linep); fileName = sourceName.replaceFirst("script in (.*) from .*", "$1"); lineNumber = linep[0]; } else { throw new Error("HtmlUnit not ready to run in compiled mode"); } exception.setLocation(fileName, lineNumber); return new JavaScriptException(exception, fileName, lineNumber); }
/** * Encapsulates the given {@link DOMException} into a Rhino-compatible exception. * * @param exception the exception to encapsulate * @return the created exception */ protected RhinoException asJavaScriptException(final DOMException exception) { final Window w = getWindow(); exception.setPrototype(w.getPrototype(exception.getClass())); exception.setParentScope(w); // get current line and file name // this method can only be used in interpreted mode. If one day we choose to use compiled mode, // then we'll have to find an other way here. final String fileName; final int lineNumber; if (Context.getCurrentContext().getOptimizationLevel() == -1) { final int[] linep = new int[1]; final String sourceName = new Interpreter().getSourcePositionFromStack(Context.getCurrentContext(), linep); fileName = sourceName.replaceFirst("script in (.*) from .*", "$1"); lineNumber = linep[0]; } else { throw new Error("HtmlUnit not ready to run in compiled mode"); } exception.setLocation(fileName, lineNumber); return new JavaScriptException(exception, fileName, lineNumber); }
thrown = NativeIterator.getStopIterationObject(scope); throw new JavaScriptException(thrown, lineSource, lineNumber);
throw new JavaScriptException("Interpreter not present", filename, lineNumber);
generatorState.returnedException = new JavaScriptException( NativeIterator.getStopIterationObject(frame.scope), frame.idata.itsSourceFile, sourceLine); throwable = new JavaScriptException(value, frame.idata.itsSourceFile, sourceLine);