Package org.mozilla.javascript

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


            org.mozilla.javascript.Context.getCurrentContext();
        Scriptable scope = getParentScope();
        Script script = interpreter.compileScript( cx,
                                                   environment,
                                                   filename );
        return script.exec( cx, scope );
    }   
       
    public static class FOM_Request extends ScriptableObject {

        Request request;
View Full Code Here


                // just update it's index so it won't get deleted soon.
                compiledScripts.addLast(et);
            }

            try {
                rv = script.exec(ctx, globalObject);
            } catch (JavaScriptException e) {
                // exception from JavaScript (possibly wrapping a Java Ex)
                if (e.getValue() instanceof Exception) {
                    Exception ex = (Exception)e.getValue();
                    throw new InterpreterException(ex, ex.getMessage(), -1,-1);
View Full Code Here

                    // this script has been compiled before,
                    // just update its index so it won't get deleted soon.
                    compiledScripts.addLast(entry);
                }

                return script.exec(cx, globalObject);
            }
        };
        try {
            return contextFactory.call(evalAction);
        } catch (InterpreterException ie) {
View Full Code Here

                fnOrScript.compile(cx, global);
                m_rhinoDbg.setCompilingFnOrScript(null);
                script = fnOrScript.getScript();

                if (script != null) retval = script.exec(cx, global);
                else retval = null;
            }
            else {
                cx.setOptimizationLevel(-1);
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

        sb.append("  [this.x] = arguments;\n");
        sb.append("}\n");
        sb.append("var f = new F('a');\n");
        sb.append("(f.x == 'a')\n");
        Script script = cx.compileString(sb.toString(), "<eval>", 1, null);
        Object result = script.exec(cx, scope);
        assertEquals(Boolean.TRUE, result);
    }

    @Test(expected = EvaluatorException.class)
    public void test_var_this() {
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

    static void evalInlineScript(Context cx, String scriptText) {
        try {
            Script script = cx.compileString(scriptText, "<command>", 1, null);
            if (script != null) {
                script.exec(cx, getShellScope());
            }
        } catch (RhinoException rex) {
            ToolErrorReporter.reportException(
                    cx.getErrorReporter(), rex);
            exitCode = EXITCODE_RUNTIME_ERROR;
View Full Code Here

                    prompt = prompts[1];
                }
                try {
                    Script script = cx.compileString(source, "<stdin>", lineno, null);
                    if (script != null) {
                        Object result = script.exec(cx, scope);
                        // Avoid printing out undefined or function definitions.
                        if (result != Context.getUndefinedValue() &&
                                !(result instanceof Function &&
                                        source.trim().startsWith("function")))
                        {
View Full Code Here

            }
            scriptCache.put(key, digest, script);
        }

        if (script != null) {
            script.exec(cx, scope);
        }
    }

    private static byte[] getDigest(Object source) {
        byte[] bytes, digest = null;
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.