public static void setIn(InputStream in) { getGlobal().setIn(in); }
void runUserScript( Context c ) { Main.processSource(c, sourceFile.getAbsolutePath()); }
/** * Main entry point. * * Process arguments as would a normal Java program. Also * create a new Context and associate it with the current thread. * Then set up the execution environment and begin to * execute scripts. */ public static void main(String args[]) { try { if (Boolean.getBoolean("rhino.use_java_policy_security")) { initJavaPolicySecuritySupport(); } } catch (SecurityException ex) { ex.printStackTrace(System.err); } int result = exec(args); if (result != 0) { System.exit(result); } }
public Object run(Context cx) { if (type == PROCESS_FILES) { processFiles(cx, args); } else if (type == EVAL_INLINE_SCRIPT) { Script script = loadScriptFromSource(cx, scriptText, "<command>", 1, null); if (script != null) { evaluateScript(script, cx, getGlobal()); } } else { throw Kit.codeBug(); } return null; }
static void processFileSecure(Context cx, Scriptable scope, String path, Object securityDomain) { Script script; if (path.endsWith(".class")) { script = loadCompiledScript(cx, path, securityDomain); } else { String source = (String)readFileOrUrl(path, true); if (source == null) { exitCode = EXITCODE_FILE_NOT_FOUND; return; } // Support the executable script #! syntax: If // the first line begins with a '#', treat the whole // line as a comment. if (source.length() > 0 && source.charAt(0) == '#') { for (int i = 1; i != source.length(); ++i) { int c = source.charAt(i); if (c == '\n' || c == '\r') { source = source.substring(i); break; } } } script = loadScriptFromSource(cx, source, path, 1, securityDomain); } if (script != null) { evaluateScript(script, cx, scope); } }
/** * Main entry point. Creates a debugger attached to a Rhino * {@link org.mozilla.javascript.tools.shell.Main} shell session. */ public static void main(String[] args) { Main main = new Main("Rhino JavaScript Debugger"); main.doBreak(); main.setExitAction(new IProxy(IProxy.EXIT_ACTION)); System.setIn(main.getIn()); System.setOut(main.getOut()); System.setErr(main.getErr()); Global global = org.mozilla.javascript.tools.shell.Main.getGlobal(); global.setIn(main.getIn()); global.setOut(main.getOut()); global.setErr(main.getErr()); main.attachTo( org.mozilla.javascript.tools.shell.Main.shellContextFactory); main.setScope(global); main.pack(); main.setSize(600, 460); main.setVisible(true); org.mozilla.javascript.tools.shell.Main.exec(args); }
Object source = readFileOrUrl(path, !isClass); byte[] digest = getDigest(source); String key = path + "_" + cx.getOptimizationLevel(); ScriptReference ref = scriptCache.get(key, digest); script = loadCompiledScript(cx, path, (byte[])source, securityDomain); } else { String strSrc = (String) source;
Scriptable scope = getShellScope(); Charset cs; String charEnc = shellContextFactory.getCharacterEncoding(); require.requireMain(cx, filename); } else { processFile(cx, getScope(filename), filename);
public Object run() { URL url = getUrlObj(filename); ProtectionDomain staticDomain = getUrlDomain(url); Main.processFileSecure(cx, scope, url.toExternalForm(), staticDomain); return null; } });
public Object run(Context cx) { if (useRequire) { require = global.installRequire(cx, modulePath, sandboxed); } if (type == PROCESS_FILES) { processFiles(cx, args); } else if (type == EVAL_INLINE_SCRIPT) { evalInlineScript(cx, scriptText); } else { throw Kit.codeBug(); } return null; }
/** * Load and execute a set of JavaScript source files. * * This method is defined as a JavaScript function. * */ public static void load(Context cx, Scriptable thisObj, Object[] args, Function funObj) { for (int i = 0; i < args.length; i++) { Main.processFile(cx, thisObj, Context.toString(args[i])); } }
ps.print(prompts[1]); Script script = loadScriptFromSource(cx, source, "<stdin>", lineno, null); if (script != null) { Object result = evaluateScript(script, cx, global); processFile(cx, global, filename);
/** * Execute the given arguments, but don't System.exit at the end. */ public static int exec(String origArgs[]) { errorReporter = new ToolErrorReporter(false, global.getErr()); shellContextFactory.setErrorReporter(errorReporter); String[] args = processOptions(origArgs); if (processStdin) fileList.add(null); if (!global.initialized) { global.init(shellContextFactory); } IProxy iproxy = new IProxy(IProxy.PROCESS_FILES); iproxy.args = args; shellContextFactory.call(iproxy); return exitCode; }
/** * Main entry point. Creates a debugger attached to a Rhino * {@link org.mozilla.javascript.tools.shell.Main} shell session. */ public static void main(String[] args) { Main main = new Main("Rhino JavaScript Debugger"); main.doBreak(); main.setExitAction(new IProxy(IProxy.EXIT_ACTION)); System.setIn(main.getIn()); System.setOut(main.getOut()); System.setErr(main.getErr()); Global global = org.mozilla.javascript.tools.shell.Main.getGlobal(); global.setIn(main.getIn()); global.setOut(main.getOut()); global.setErr(main.getErr()); main.attachTo( org.mozilla.javascript.tools.shell.Main.shellContextFactory); main.setScope(global); main.pack(); main.setSize(600, 460); main.setVisible(true); org.mozilla.javascript.tools.shell.Main.exec(args); }
Object source = readFileOrUrl(path, !isClass); byte[] digest = getDigest(source); String key = path + "_" + cx.getOptimizationLevel(); ScriptReference ref = scriptCache.get(key, digest); script = loadCompiledScript(cx, path, (byte[])source, securityDomain); } else { String strSrc = (String) source;
Scriptable scope = getShellScope(); Charset cs; String charEnc = shellContextFactory.getCharacterEncoding(); require.requireMain(cx, filename); } else { processFile(cx, getScope(filename), filename);
public Object run() { URL url = getUrlObj(filename); ProtectionDomain staticDomain = getUrlDomain(url); try { Main.processFileSecure(cx, scope, url.toExternalForm(), staticDomain); } catch (IOException ioex) { throw new RuntimeException(ioex); } return null; } });
public Object run(Context cx) { if (useRequire) { require = global.installRequire(cx, modulePath, sandboxed); } if (type == PROCESS_FILES) { processFiles(cx, args); } else if (type == EVAL_INLINE_SCRIPT) { evalInlineScript(cx, scriptText); } else { throw Kit.codeBug(); } return null; }