Package org.mozilla.javascript

Examples of org.mozilla.javascript.Script.exec()


  public void executeScript(String filename)
  {
    Script s = loadedScripts.get(filename);
    try
    {
      s.exec(context, scope);
    }
    catch(Exception e)
    {
      context.reportRuntimeError("Error in script", filename, -1, "", -1);
    }
View Full Code Here


 
  private Object runScript(final String scriptSourceText) {
    return contextFactory.call(new ContextAction() {
      public Object run(Context context) {
        Script script = context.compileString(scriptSourceText, "", 1, null);
        return script.exec(context, global);
      }
    });
 
}
View Full Code Here

        cx.setOptimizationLevel(-1);
        Script script = cx.compileReader(new InputStreamReader(
                Bug482203.class.getResourceAsStream("conttest.js")),
                "", 1, null);
        Scriptable scope = cx.initStandardObjects();
        script.exec(cx, scope);
        for(;;)
        {
            Object cont = ScriptableObject.getProperty(scope, "c");
            if(cont == null)
            {
View Full Code Here

    final Context cx = ContextFactory.getGlobal().enterContext();
    try {
            Scriptable topScope = cx.initStandardObjects();
        topScope.put("javaNameGetter", topScope, new JavaNameGetter());
        Script script = cx.compileString(scriptCode, "myScript", 1, null);
        script.exec(cx, topScope);
    } finally {
        Context.exit();
    }
  }
}
View Full Code Here

                    throw Utils.makeError(cx, thisObj, "Invalid compiled script argument");
                }
                return interpretScript(cx, context, scriptSource, fileName);

            } else {
                return compiledScript.exec(cx, context);
            }
        }

        @JSStaticFunction
        @SuppressWarnings("unused")
View Full Code Here

            Script compiled = getCompiledScript(cx, code, fileName);
            if (compiled == null) {
                // The script is probably too large to compile
                return interpretScript(cx, scope, code, fileName);
            }
            return compiled.exec(cx, scope);
        }

        private static Object interpretScript(Context cx, Scriptable scope, String code, String fileName)
        {
            if (log.isDebugEnabled()) {
View Full Code Here

        throws Exception {
        org.mozilla.javascript.Context cx =
            org.mozilla.javascript.Context.getCurrentContext();
        Scriptable scope = getParentScope();
        Script script = getInterpreter().compileScript(cx, filename);
        return script.exec( cx, scope );
    }

    /**
     * Setup an object so that it can access the information provided to regular components.
     * This is done by calling the various Avalon lifecycle interfaces implemented by the object, which
View Full Code Here

    private Object[] compileScript(Context cx, String scriptStr, Scriptable scriptScope, File f) {
        int opt = cx.getOptimizationLevel();
        cx.setOptimizationLevel(-1);
        Script script = cx.compileString(scriptStr, f.getName(), 1, null);
        script.exec(cx, scriptScope);
        Object[] ids = scriptScope.getIds();
        cx.setOptimizationLevel(opt);
        script = cx.compileString(scriptStr, f.getName(), 1, null);
        script.exec(cx, scriptScope);
        return ids;
View Full Code Here

        Script script = cx.compileString(scriptStr, f.getName(), 1, null);
        script.exec(cx, scriptScope);
        Object[] ids = scriptScope.getIds();
        cx.setOptimizationLevel(opt);
        script = cx.compileString(scriptStr, f.getName(), 1, null);
        script.exec(cx, scriptScope);
        return ids;
    }

    static class RhinoContextFactory extends ContextFactory {
        public boolean hasFeature(Context cx, int feature) {
View Full Code Here

                ScriptSourceEntry entry =
                    (ScriptSourceEntry)compiledScripts.get(sourceURI);
                long lastMod = entry.getSource().getLastModified();
                Script script = entry.getScript(context, this.scope, false);
                if (lastExecTime == 0 || lastMod > lastExecTime) {
                    script.exec(context, thrScope);
                    thrScope.put(LAST_EXEC_TIME, thrScope,
                                 new Long(System.currentTimeMillis()));
                    ((ThreadScope)thrScope).reset();
                }
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.