Package org.mozilla.javascript

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


    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

  }
 
  protected Object evaluateExpression(String type, String expression)
  {
    Script compiledExpression = getCompiledExpression(expression);
    Object value = compiledExpression.exec(context, scope);
   
    Class typeClass = getTypeClass(type);
    Object javaValue;
    try
    {
View Full Code Here

   
    Context ctx = cf_global.enterContext(vm.cx);
    try {
     
      Script scr = ctx.compileString(code, filename, 1, null);     
      Object result = scr.exec(ctx, vm.global);
     
      if (handle_retval) {
        if (result instanceof String) {
          return (String) result;
        } else if (result == Context.getUndefinedValue()){
View Full Code Here

      final NativeObject prototype = new NativeObject();
      ScriptableObject.putProperty(htmlelement, "prototype", prototype);
      final NativeObject external = new NativeObject();
      ScriptableObject.putProperty(scope, "external", external);

      sc.exec(cx, scope);
      buildFile.close();
      goodExecution = true;
    } catch (final org.mozilla.javascript.EcmaError e) {
      goodExecution = false;
    } catch (final FileNotFoundException e) {
View Full Code Here

   */
  public static void executeJsFile(final Context cx, final Scriptable thisObj, final String filename) throws WinkBuildException {
    try {
      final Reader buildFile = new FileReader(new File(filename));
      final Script sc = cx.compileReader(buildFile, filename, 1, null);
      sc.exec(cx, thisObj);
      buildFile.close();
    } catch (final FileNotFoundException e) {
      throw new WinkBuildException(e);
    } catch (final IOException e) {
      throw new WinkBuildException(e);
View Full Code Here

            // just update it's index so it won't get deleted soon.
            compiledScripts.addLast(et);
        }
        Object rv = null;
        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

            // just update it's index so it won't get deleted soon.
            compiledScripts.addLast(et);
        }
        Object rv = null;
        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

            if (cl != null) {
               cx.setApplicationClassLoader(cl);
            }
            this.scriptScope = new ImporterTopLevel( cx, true );
            Script compiledScript = cx.compileString(scriptCode, fileName, 1, null);
            compiledScript.exec(cx, scriptScope);
            addContexts(scriptScope, context);

        } finally {
            Context.exit();
        }
View Full Code Here

        org.mozilla.javascript.Context cx =
            org.mozilla.javascript.Context.getCurrentContext();
        try {
            Scriptable scope = getParentScope();
            Script script = interpreter.compileScript(cx, environment, filename);
            return script.exec(cx, scope);
        } catch (JavaScriptException e) {
            throw e;
        } catch (Exception e) {
            throw new JavaScriptException(e);
        }
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.