Package org.mozilla.javascript

Examples of org.mozilla.javascript.Script


  public void testScriptWithMultipleContinuations() {
      Context cx = Context.enter();
      try {
          cx.setOptimizationLevel(-1); // must use interpreter mode
          Script script = cx.compileString("myObject.f(3) + myObject.g(3) + 2;",
                  "test source", 1, null);
          cx.executeScriptWithContinuations(script, globalScope);
          fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
          try {
View Full Code Here


  public void testScriptWithNestedContinuations() {
      Context cx = Context.enter();
      try {
          cx.setOptimizationLevel(-1); // must use interpreter mode
          Script script = cx.compileString("myObject.g( myObject.f(1) ) + 2;",
                  "test source", 1, null);
          cx.executeScriptWithContinuations(script, globalScope);
          fail("Should throw ContinuationPending");
      } catch (ContinuationPending pending) {
          try {
View Full Code Here

 
  public void testErrorOnEvalCall() {
      Context cx = Context.enter();
      try {
          cx.setOptimizationLevel(-1); // must use interpreter mode
          Script script = cx.compileString("eval('myObject.f(3);');",
                  "test source", 1, null);
          cx.executeScriptWithContinuations(script, globalScope);
          fail("Should throw IllegalStateException");
      } catch (WrappedException we) {
          Throwable t = we.getWrappedException();
View Full Code Here

  }

  private Object runScript(final String scriptSourceText) {
    return this.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

                    lineno++;
                    if (cx.stringIsCompilableUnit(source))
                        break;
                    ps.print(prompts[1]);
                }
                Script script = loadScriptFromSource(cx, source, "<stdin>",
                                                     lineno, null);
                if (script != null) {
                    Object result = evaluateScript(script, cx, global);
                    // Avoid printing out undefined or function definitions.
                    if (result != Context.getUndefinedValue() &&
View Full Code Here

    }

    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) {
View Full Code Here

        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 {
View Full Code Here

        return null;
    }

    private Script getScriptFromReader(String key, Reader reader) {
        synchronized (scriptCacheMap) {
            Script script = scriptCacheMap.get(key);
            if (script == null) {
                Context ctx = Context.enter();
                try {
                    ctx.setOptimizationLevel(-1);
                    script = ctx.compileReader(reader, "", 0, null);
View Full Code Here

        }
    }

    private Script getScriptFromString(String string) {
        synchronized (scriptCacheMap) {
            Script script = scriptCacheMap.get(string);
            if (script == null) {
                Context ctx = Context.enter();
                try {
                    ctx.setOptimizationLevel(-1);
                    script = ctx.compileString(string, "", 0, null);
View Full Code Here

    try {
      String scriptContents = FileUtils.readFileToString(new File("/Users/james/IBM/Code/dwb/src/main/webapp/js/build/amd_loader/dojo.js"));
   
      scriptContents = "djConfig = {buildReference: false, packages:[{name:'build', lib:'.', location:'/Users/james/IBM/Code/dwb/src/main/webapp/js/build/bdbuild'}]};" + scriptContents;
     
      Script script = cx.compileString(scriptContents, "testing", 1, null);
   
      String[] test = {
          "load=build",
          "baseUrl=/Users/james/Code/JavaScript/Libraries/DTK/gh/dojo",
          "action=release",
          "releaseDir=/tmp",         
         
          "profile=/var/folders/vW/vWWvubkrGQigEDaT1bf7mk+++TI/-Tmp-/dojo_web_builder2882495873173706775.tmp/Rb9dt193EcK9g6GjQjJOhhuL0NE_/build.profile.js",
          };
      /*
      baseUrl=
      action=release
      releaseDir=/var/folders/vW/vWWvubkrGQigEDaT1bf7mk+++TI/-Tmp-/dojo_web_builder176030933906566663.tmp/Rb9dt193EcK9g6GjQjJOhhuL0NE_
      load=build
      profile=/var/folders/vW/vWWvubkrGQigEDaT1bf7mk+++TI/-Tmp-/dojo_web_builder176030933906566663.tmp/Rb9dt193EcK9g6GjQjJOhhuL0NE_/build.profile.js
      */
     
      ScriptableObject.putConstProperty(topScope, "arguments", test);
     
      // Exec the build script.
      script.exec(cx, topScope);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
 
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Script

Copyright © 2018 www.massapicom. 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.