@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (script != null) { return script.exec(cx, scope); } return Undefined.instance; }
@Override public Object doRun(final Context cx) { return script.exec(cx, scope); }
@Override public Object doRun(final Context cx) { return script.exec(cx, scope); }
@Override public Object doRun(final Context cx) { return script.exec(cx, scope); }
@Override public Object doRun(final Context cx) { return script.exec(cx, scope); }
@Override public Object doRun(final Context cx) { return script.exec(cx, scope); }
public Object run(Context cx) { if (f != null) return f.call(cx, scope, scope, args); else return s.exec(cx, scope); }
public Object run(Context cx) { ScriptableObject global = ScriptRuntime.getGlobal(cx); script.exec(cx, global); return global; } });
/** * 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; } }
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); }
/** * 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); }
/** * Load and execute a script compiled to a class file. * <p> * This method is defined as a JavaScript function. * When called as a JavaScript function, a single argument is * expected. This argument should be the name of a class that * implements the Script interface, as will any script * compiled by jsc. * * @exception IllegalAccessException if access is not available * to the class * @exception InstantiationException if unable to instantiate * the named class */ public static void loadClass(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws IllegalAccessException, InstantiationException { Class<?> clazz = getClass(args); if (!Script.class.isAssignableFrom(clazz)) { throw reportRuntimeError("msg.must.implement.Script"); } Script script = (Script) clazz.newInstance(); script.exec(cx, thisObj); }
public Object run(Context cx) { ScriptableObject global = getGlobal(cx); // get the command line arguments and define "arguments" // array in the top-level object Object[] argsCopy = new Object[args.length]; System.arraycopy(args, 0, argsCopy, 0, args.length); Scriptable argsObj = cx.newArray(global, argsCopy); global.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM); script.exec(cx, global); return null; } });
@Test public void run() throws RhinoException { try { final Scriptable scope = getScope(); final Map<String, Object> implicitObjects = getImplicitObjects(); for (Entry<String, Object> entry : implicitObjects.entrySet()) { scope.put(entry.getKey(), scope, entry.getValue()); } for (Script compiledScript : this.compiledScripts) { compiledScript.exec(context, scope); } } catch (JavaScriptException jsex) { throw jsex; } }
public static Object evaluateScript(Script script, Context cx, Scriptable scope) { try { return script.exec(cx, scope); } 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 Context.getUndefinedValue(); }