Java 类org.mozilla.javascript.tools.shell.Global 实例源码

项目:whackpad    文件:DoctestsTest.java   
@Test
public void runDoctest() throws Exception {
    ContextFactory factory = ContextFactory.getGlobal();
    Context cx = factory.enterContext();
    try {
        cx.setOptimizationLevel(optimizationLevel);
        Global global = new Global(cx);
        // global.runDoctest throws an exception on any failure
        int testsPassed = global.runDoctest(cx, global, source, name, 1);
        System.out.println(name + "(" + optimizationLevel + "): " +
                testsPassed + " passed.");
        assertTrue(testsPassed > 0);
    } catch (Exception ex) {
      System.out.println(name + "(" + optimizationLevel + "): FAILED due to "+ex);
      throw ex;
    } finally {
        Context.exit();
    }  
}
项目:rhino-android    文件:DoctestsTest.java   
@Test
public void runDoctest() throws Exception {
    Context cx = RhinoAndroidHelper.prepareContext();
    try {
        cx.setOptimizationLevel(optimizationLevel);
        Global global = new Global(cx);
        TestUtils.addAssetLoading(global);
        // global.runDoctest throws an exception on any failure
        int testsPassed = global.runDoctest(cx, global, source, name, 1);
        System.out.println(name + "(" + optimizationLevel + "): " +
                testsPassed + " passed.");
        assertTrue(testsPassed > 0);
    } catch (Exception ex) {
      System.out.println(name + "(" + optimizationLevel + "): FAILED due to "+ex);
      throw ex;
    } finally {
        Context.exit();
    }
}
项目:code404    文件:DoctestsTest.java   
@Test
public void runDoctest() throws Exception {
    ContextFactory factory = ContextFactory.getGlobal();
    Context cx = factory.enterContext();
    try {
        cx.setOptimizationLevel(optimizationLevel);
        Global global = new Global(cx);
        // global.runDoctest throws an exception on any failure
        int testsPassed = global.runDoctest(cx, global, source, name, 1);
        System.out.println(name + "(" + optimizationLevel + "): " +
                testsPassed + " passed.");
        assertTrue(testsPassed > 0);
    } catch (Exception ex) {
      System.out.println(name + "(" + optimizationLevel + "): FAILED due to "+ex);
      throw ex;
    } finally {
        Context.exit();
    }
}
项目:rhino-jscover    文件:DoctestsTest.java   
@Test
public void runDoctest() throws Exception {
    ContextFactory factory = ContextFactory.getGlobal();
    Context cx = factory.enterContext();
    try {
        cx.setOptimizationLevel(optimizationLevel);
        Global global = new Global(cx);
        // global.runDoctest throws an exception on any failure
        int testsPassed = global.runDoctest(cx, global, source, name, 1);
        System.out.println(name + "(" + optimizationLevel + "): " +
                testsPassed + " passed.");
        assertTrue(testsPassed > 0);
    } catch (Exception ex) {
      System.out.println(name + "(" + optimizationLevel + "): FAILED due to "+ex);
      throw ex;
    } finally {
        Context.exit();
    }
}
项目:astor    文件:DoctestsTest.java   
@Test
public void runDoctest() throws Exception {
    ContextFactory factory = ContextFactory.getGlobal();
    Context cx = factory.enterContext();
    try {
        cx.setOptimizationLevel(optimizationLevel);
        Global global = new Global(cx);
        // global.runDoctest throws an exception on any failure
        int testsPassed = global.runDoctest(cx, global, source, name, 1);
        System.out.println(name + "(" + optimizationLevel + "): " +
                testsPassed + " passed.");
        assertTrue(testsPassed > 0);
    } catch (Exception ex) {
      System.out.println(name + "(" + optimizationLevel + "): FAILED due to "+ex);
      throw ex;
    } finally {
        Context.exit();
    }
}
项目:Rhino-Prov-Mod    文件:DoctestsTest.java   
@Test
public void runDoctest() throws Exception {
    ContextFactory factory = ContextFactory.getGlobal();
    Context cx = factory.enterContext();
    try {
        cx.setOptimizationLevel(optimizationLevel);
        Global global = new Global(cx);
        // global.runDoctest throws an exception on any failure
        int testsPassed = global.runDoctest(cx, global, source, name, 1);
        System.out.println(name + "(" + optimizationLevel + "): " +
                testsPassed + " passed.");
        assertTrue(testsPassed > 0);
    } catch (Exception ex) {
      System.out.println(name + "(" + optimizationLevel + "): FAILED due to "+ex);
      throw ex;
    } finally {
        Context.exit();
    }
}
项目:imcjava    文件:ImcScript.java   
protected void init() throws Exception {
    context = Context.enter();
    global = new Global();
    global.init(context);

    ScriptableObject.defineClass(global, ScriptableMessage.class);
    ScriptableObject.defineClass(global, ScriptableIMC.class);

    Object o = Context.javaToJS(new ScriptableConsole(), global);
    ScriptableObject.putProperty(global, "console", o);

    o = Context.javaToJS(new ScriptableGui(), global);
    ScriptableObject.putProperty(global, "gui", o);

    Scriptable imc = context.newObject(global, "IMC", null);
    global.put("imc", global, imc);
}
项目:whackpad    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:whackpad    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:rhino-android    文件:TestUtils.java   
public static void loadAsset(Context cx, Scriptable thisObj,
                             Object[] args, Function funObj)
{
    for (Object arg : args) {
        String file = Context.toString(arg);
        Global.load(cx, thisObj, new Object[]{copyFromAssets(file)}, funObj);
    }
}
项目:rhino-android    文件:CaliperSpiderBenchmark.java   
@BeforeExperiment
@SuppressWarnings("unused")
void create()
    throws IOException
{
    cx = Context.enter();
    cx.setOptimizationLevel(optLevel);
    cx.setLanguageVersion(Context.VERSION_ES6);
    scope = new Global(cx);

    for (String bn : BENCHMARKS) {
        compileScript(cx, bn);
    }
}
项目:rhino-android    文件:CaliperObjectBenchmark.java   
@BeforeExperiment
@SuppressWarnings("unused")
void create()
    throws IOException
{
    cx = Context.enter();
    cx.setOptimizationLevel(optLevel);
    cx.setLanguageVersion(Context.VERSION_ES6);

    scope = new Global(cx);
    runCode(cx, scope, "testsrc/benchmarks/caliper/fieldTests.js");

    Object[] sarray = new Object[stringKeys];
    for (int i = 0; i < stringKeys; i++) {
        int len = rand.nextInt(49) + 1;
        char[] c = new char[len];
        for (int cc = 0; cc < len; cc++) {
            c[cc] = (char) ('a' + rand.nextInt(25));
        }
        sarray[i] = new String(c);
    }
    strings = cx.newArray(scope, sarray);

    Object[] iarray = new Object[intKeys];
    for (int i = 0; i < intKeys; i++) {
        iarray[i] = rand.nextInt(10000);
    }
    ints = cx.newArray(scope, iarray);
}
项目:rhino-android    文件:V8Benchmark.java   
private void runTest(int optLevel)
    throws IOException
{


    Context cx = RhinoAndroidHelper.prepareContext();
    cx.setLanguageVersion(Context.VERSION_1_8);
    cx.setOptimizationLevel(optLevel);
    Global root = new Global(cx);
    TestUtils.addAssetLoading(root);
    root.put("RUN_NAME", root, "V8-Benchmark-" + optLevel);
    Object result = cx.evaluateString(root, TestUtils.readAsset(TEST_SRC), TEST_SRC, 1, null);
    results.put(optLevel, result.toString());
}
项目:rhino-android    文件:SunSpiderBenchmark.java   
private void runTest(int optLevel)
    throws IOException
{

    Context cx = RhinoAndroidHelper.prepareContext();
    cx.setLanguageVersion(Context.VERSION_1_8);
    cx.setOptimizationLevel(optLevel);
    Global root = new Global(cx);
    TestUtils.addAssetLoading(root);
    root.put("RUN_NAME", root, "SunSpider-" + optLevel);
    Object result = cx.evaluateString(root, TestUtils.readAsset(TEST_SRC), TEST_SRC, 1, null);
    results.put(optLevel, result.toString());
}
项目:rhino-android    文件:ExternalArrayTest.java   
@Before
public void init()
{
    cx = RhinoAndroidHelper.prepareContext();
    cx.setLanguageVersion(Context.VERSION_1_8);
    cx.setGeneratingDebug(true);

    Global global = new Global(cx);
    TestUtils.addAssetLoading(global);
    root = cx.newObject(global);
}
项目:JsSandbox    文件:JsScriptFunctionUtils.java   
@JsScriptFuntion
public static Object readFile(Context cx, Scriptable thisObj,
                              Object[] args, Function funObj) throws IOException
{
    List<File> dirList = readOnDirs;
    for (int i = 0; i < args.length; i++) {
        String filename = Context.toString(args[i]);
        if (!isPathInsideOneOfListedDirs(dirList, filename)) {
            throw new RuntimeException("File " + filename
                    + " must be inside on one of those dirs: " + dirList);
        }
    }
    return Global.readFile(cx, thisObj, args, funObj);
}
项目:code404    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:code404    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:ef-orm    文件:E4XTest.java   
public Object run(Context context) {
    try {
        Global global = new Global(context); // 参考注意事项2
        InputStream ins = new FileInputStream(file);

        Reader reader = new InputStreamReader(ins);
        Object result = context.evaluateReader(global, reader, file.getName(), 1, null);
        return Context.toString(result);
    } catch (Exception e) {
        LogUtil.exception(e);
    }
    return "!!!ERROR!!!";
}
项目:S3F    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:S3F    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:rhino-jscover    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:rhino-jscover    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:astor    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:astor    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:Rhino-Prov-Mod    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:Rhino-Prov-Mod    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:minium    文件:RhinoEngine.java   
public <T> RhinoEngine(final RhinoProperties rhinoProperties) {
    this.executorService = Executors.newSingleThreadExecutor(new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            Preconditions.checkState(executionThread == null, "Only one thread is supported");
            executionThread = FACTORY.newThread(r);
            return executionThread;
        }
    });

    // this ensures a single thread for this engine
    runWithContext(new RhinoCallable<Void, RuntimeException>() {
        @Override
        protected Void doCall(Context cx, Scriptable s) {
            try {
                Global global = new Global(cx);
                RequireProperties require = rhinoProperties.getRequire();
                if (require != null) {
                    List<String> modulePathURIs = getModulePathURIs(require);
                    LOGGER.debug("Module paths: {}", modulePathURIs);
                    global.installRequire(cx, modulePathURIs, require.isSandboxed());
                }
                ClassLoader classloader = Thread.currentThread().getContextClassLoader();
                // we need to load compat/timeout.js because rhino does not have setTimeout, setInterval, etc.
                try (Reader in = new InputStreamReader(classloader.getResourceAsStream("compat/timeout.js"))) {
                    cx.evaluateReader(global, in, "compat/timeout.js", 1, null);
                }
                scope = global;
                prototype = new NativeObject();

                scope.put("__prototype", scope, prototype);

                return null;
            } catch (IOException e) {
                throw Throwables.propagate(e);
            }
        }
    });
}
项目:closure-compiler-old    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:closure-compiler-old    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:celos    文件:TestConfigurationParser.java   
Object evaluateTestConfig(Reader reader, String desc) throws IOException {
    Global scope = jsConfigParser.createGlobalScope();

    Object wrappedContext = Context.javaToJS(this, scope);
    Map jsProperties = Maps.newHashMap();
    jsProperties.put("testConfigurationParser", wrappedContext);
    jsConfigParser.putPropertiesInScope(jsProperties, scope);

    InputStream scripts = getClass().getResourceAsStream("celos-ci-scripts.js");
    jsConfigParser.evaluateReader(scope, new InputStreamReader(scripts), "celos-ci-scripts.js");
    return jsConfigParser.evaluateReader(scope, reader, desc);
}
项目:celos    文件:WorkflowConfigurationParser.java   
public void importDefaultsIntoScope(String label, Global scope) throws IOException {
    File defaultsFile = new File(defaultsDir, label + "." + WORKFLOW_FILE_EXTENSION);
    LOGGER.info("Loading defaults: " + defaultsFile);
    FileReader fileReader = new FileReader(defaultsFile);
    String fileName = defaultsFile.toString();
    jsConfigParser.evaluateReader(scope, fileReader, fileName);
}
项目:celos    文件:JSConfigParser.java   
public Global createGlobalScope() {
    Global scope = new Global();
    scope.initStandardObjects(context, true);
    Object wrappedMapper = Context.javaToJS(Util.JSON_READER, scope);
    ScriptableObject.putProperty(scope, "celosReader", wrappedMapper);
    Object wrappedScope = Context.javaToJS(scope, scope);
    ScriptableObject.putProperty(scope, "celosScope", wrappedScope);

    return scope;
}
项目:celos    文件:JSConfigParser.java   
public void putPropertiesInScope(Map<String, Object> jsParameters, Global scope) {
    if (jsParameters != null) {
        for (String key : jsParameters.keySet()) {
            ScriptableObject.putProperty(scope, key, jsParameters.get(key));
        }
    }
}
项目:imcjava    文件:ScriptableMessage.java   
public static void main(String[] args) throws Exception {
    // initialization
    Context cx = Context.enter();
    Global s = new Global();
    s.init(cx);
    cx.evaluateString(s, "importClass(java.lang.Thread);", "x", 0, null);
    ScriptableObject.defineClass(s, ScriptableMessage.class);
    // end of initialization

    cx.evaluateString(s, "m = new Message('EstimatedState');\n"
            + "spawn(function() {print('Hello!'); Thread.sleep(5000); print('Goodbye!');});\n"
            + "m.ref = 'NED_LLD';\n" + "m.x = -100.567;\n" + "m.p = (Math.PI / 180) * 10;\n" + "m.dump();",
            "inline", 1, null);
    Context.exit();
}
项目:imcjava    文件:KrakenScript.java   
public static void main(String[] args) throws Exception {
    // initialization
    Context cx = Context.enter();
    Global s = new Global();
    s.init(cx);
    cx.evaluateString(s, "importClass(java.lang.Thread);", "x", 0, null);
    ScriptableObject.defineClass(s, KrakenScript.class);
    // end of initialization

    cx.evaluateString(s, "m = new Message('EstimatedState');\n"
            + "spawn(function() {print('Hello!'); Thread.sleep(5000); print('Goodbye!');});\n"
            + "m.ref = 'NED_LLD';\n" + "m.x = -100.567;\n" + "m.p = (Math.PI / 180) * 10;\n" + "m.dump();",
            "inline", 1, null);
    Context.exit();
}
项目:closure-compiler-copy    文件:Main.java   
/**
 * Entry point for embedded applications.  This method attaches
 * to the global {@link ContextFactory} with a scope of a newly
 * created {@link Global} object.  No I/O redirection is performed
 * as with {@link #main(String[])}.
 */
public static Main mainEmbedded(String title) {
    ContextFactory factory = ContextFactory.getGlobal();
    Global global = new Global();
    global.init(factory);
    return mainEmbedded(factory, global, title);
}
项目:closure-compiler-copy    文件:Main.java   
/**
 * Helper method for {@link #mainEmbedded(String)}, etc.
 */
private static Main mainEmbeddedImpl(ContextFactory factory,
                                     Object scopeProvider,
                                     String title) {
    if (title == null) {
        title = "Rhino JavaScript Debugger (embedded usage)";
    }
    Main main = new Main(title);
    main.doBreak();
    main.setExitAction(new IProxy(IProxy.EXIT_ACTION));

    main.attachTo(factory);
    if (scopeProvider instanceof ScopeProvider) {
        main.setScopeProvider((ScopeProvider)scopeProvider);
    } else {
        Scriptable scope = (Scriptable)scopeProvider;
        if (scope instanceof Global) {
            Global global = (Global)scope;
            global.setIn(main.getIn());
            global.setOut(main.getOut());
            global.setErr(main.getErr());
        }
        main.setScope(scope);
    }

    main.pack();
    main.setSize(600, 460);
    main.setVisible(true);
    return main;
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:Main.java   
public static Global getGlobal() {
    return global;
}
项目:Auto.js    文件:Main.java   
public static Global getGlobal() {
    return global;
}