@Override public Object doRun(final Context cx) { return cx.compileString(sourceCode, sourceName, startLine, null); }
@Override public Object doRun(final Context cx) { return cx.compileString(source, sourceName, startLine, null); }
@Override public Object doRun(final Context cx) { return cx.compileString(source, sourceName, startLine, null); }
@Override public Object doRun(final Context cx) { return cx.compileString(source, sourceName, startLine, null); }
@Override public Object doRun(final Context cx) { return cx.compileString(sourceCode, sourceName, startLine, null); }
/** * Compiles the source in the given string. * <p> * Returns a script that may later be executed. * * @param source the source string * @param sourceName a string describing the source, such as a filename * @param lineno the starting line number for reporting errors. Use * 0 if the line number is unknown. * @param securityDomain an arbitrary object that specifies security * information about the origin or owner of the script. For * implementations that don't care about security, this value * may be null. * @return a script that may later be executed * @see net.sourceforge.htmlunit.corejs.javascript.Script */ public final Script compileString(String source, String sourceName, int lineno, Object securityDomain) { if (lineno < 0) { // For compatibility IllegalArgumentException can not be thrown here lineno = 0; } return compileString(source, null, null, sourceName, lineno, securityDomain); }
/** * Evaluate a JavaScript source string. * * The provided source name and line number are used for error messages * and for producing debug information. * * @param scope the scope to execute in * @param source the JavaScript source * @param sourceName a string describing the source, such as a filename * @param lineno the starting line number * @param securityDomain an arbitrary object that specifies security * information about the origin or owner of the script. For * implementations that don't care about security, this value * may be null. * @return the result of evaluating the string * @see net.sourceforge.htmlunit.corejs.javascript.SecurityController */ public final Object evaluateString(Scriptable scope, String source, String sourceName, int lineno, Object securityDomain) { Script script = compileString(source, sourceName, lineno, securityDomain); if (script != null) { return script.exec(this, scope); } else { return null; } }
/** * Executes the specified script code in the scope of this window. * This is used only when eval() is called on a Window other than the starting scope * @param scriptCode some JavaScript code * @return the evaluation result */ public Object custom_eval(final String scriptCode) { final Context context = Context.getCurrentContext(); final Script script = context.compileString(scriptCode, "eval body", 0, null); return script.exec(context, this); }
/** * Executes the specified script code in the scope of this window. * This is used only when eval() is called on a Window other than the starting scope * @param scriptCode some JavaScript code * @return the evaluation result */ public Object custom_eval(final String scriptCode) { final Context context = Context.getCurrentContext(); final Script script = context.compileString(scriptCode, "eval body", 0, null); return script.exec(context, this); }
@Override public Object run(final Context cx) { cx.setOptimizationLevel(-1); final Script script = cx.compileString(scriptSource, scriptName, 0, null); return cx.decompileScript(script, 4); } };
@Override public Object run(final Context cx) { cx.setOptimizationLevel(-1); final Script script = cx.compileString(scriptSource, scriptName, 0, null); return cx.decompileScript(script, 4); } };
/** * Executes the specified script code in the scope of this window. * This is used only when eval() is called on a Window other than the starting scope * @param scriptCode some JavaScript code * @return the evaluation result */ public Object custom_eval(final String scriptCode) { final Context context = Context.getCurrentContext(); final Script script = context.compileString(scriptCode, "eval body", 0, null); return script.exec(context, this); }
private static Script compile(Context cx, String source) { int[] linep = { 0 }; String filename = Context.getSourcePositionFromStack(linep); if (filename == null) { filename = "<Script object>"; linep[0] = 1; } ErrorReporter reporter; reporter = DefaultErrorReporter.forEval(cx.getErrorReporter()); return cx.compileString(source, null, reporter, filename, linep[0], null); }
return super.compileString(source, compiler, compilationErrorReporter, sourceName, lineno, securityDomain);
return super.compileString(source, compiler, compilationErrorReporter, sourceName, lineno, securityDomain);
return super.compileString(source, compiler, compilationErrorReporter, sourceName, lineno, securityDomain);
public static Script loadScriptFromSource(Context cx, String scriptSource, String path, int lineno, Object securityDomain) { try { return cx.compileString(scriptSource, path, lineno, securityDomain); } catch (EvaluatorException ee) { // Already printed message. exitCode = EXITCODE_RUNTIME_ERROR; } catch (RhinoException rex) { ToolErrorReporter.reportException( cx.getErrorReporter(), rex); exitCode = EXITCODE_RUNTIME_ERROR; } catch (VirtualMachineError ex) { // Treat StackOverflow and OutOfMemory as runtime errors ex.printStackTrace(); String msg = ToolErrorReporter.getMessage( "msg.uncaughtJSException", ex.toString()); exitCode = EXITCODE_RUNTIME_ERROR; Context.reportError(msg); } return null; }
switch (type) { case IPROXY_COMPILE_SCRIPT: cx.compileString(text, url, 1, null); break;
cx.setGeneratingDebug(false); try { Callable script = (Callable)cx.compileString(expr, "", 0, null); Object result = script.call(cx, frame.scope, frame.thisObj, ScriptRuntime.emptyArgs);
Script script = cx.compileString((String)x, evaluator, reporter, sourceName, 1, null); evaluator.setEvalScriptFlag(script);