Package org.mozilla.javascript

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


            JavaScriptEvaluator.createJSExpression(expr);
         
          //compile the default expression to catch syntax errors
          try
          {
            context.compileString(jsExpr.getDefaultExpression(),
                "expression", 0, null);
          }
          catch (EvaluatorException e)
          {
            ++errorCount;
View Full Code Here


  private String sm_eval(String filename, String code, boolean handle_retval) {
   
    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;
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

    @Override public Object compile(String script) {
        Context ctx = Context.enter();
        try {
            ctx.setWrapFactory(wrapFactory);
            ctx.setOptimizationLevel(optimizationLevel);
            return ctx.compileString(script, generateScriptName(), 1, null);
        } finally {
            Context.exit();
        }
    }
View Full Code Here

    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

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

       
        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

    }

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

  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

  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

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.