Examples of compileString()


Examples of org.mozilla.javascript.Context.compileString()

    try
    {
      for( String name : properties.keySet() )
        ScriptableObject.putProperty( scope, name, Context.javaToJS( properties.get( name ), scope ) );

      Script script = context.compileString( scriptText, "Script", 0, null );

      return script.exec( context, scope );
    }
    finally
    {
View Full Code Here

Examples of org.mozilla.javascript.Context.compileString()

                    // Resolve function name
                    //
                    Object fun;
                    try {
                        fun = context.compileString(funName, null, 1, null).exec (context, thrScope);
                    } catch (EcmaError ee) {
                        throw new ResourceNotFoundException (
                             "Function \"javascript:" + funName + "()\" not found");
                    }
View Full Code Here

Examples of org.mozilla.javascript.Context.compileString()

       
        initScope(context,scope);
       
        String functionName = "init";
        try {
            Object fun = context.compileString(functionName, null, 1, null).exec(context, scope);
            if (fun != null && fun instanceof Function) {
                try {
                    ((Function) fun).call(context, scope, scope, new Object[] {});
                } catch (EcmaError ee) {
                    _logger.error("Error initializing module " + getName() + " by script function init()", ee);
View Full Code Here

Examples of org.mozilla.javascript.Context.compileString()

    }

    private void compile() {
        Context ctx = Context.enter();
        try {
            this.script = ctx.compileString(getExpression(), "", 1, null);
        } finally {
            Context.exit();
        }
    }
View Full Code Here

Examples of org.mozilla.javascript.Context.compileString()

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

Examples of org.mozilla.javascript.Context.compileString()

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

Examples of org.mozilla.javascript.Context.compileString()

  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

Examples of org.mozilla.javascript.Context.compileString()

   */
  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

Examples of org.mozilla.javascript.Context.compileString()

  public void doTest(final String scriptCode) throws Exception {
    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

Examples of org.mozilla.javascript.Context.compileString()

  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
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.