Examples of CompiledScript


Examples of javax.script.CompiledScript

    }

    public void testCompilable() throws Exception {
        assertTrue("Engine should implement Compilable", engine instanceof Compilable);
        Compilable cengine = (Compilable) engine;
        CompiledScript script = cengine.compile("40 + 2");
        assertEquals(Integer.valueOf(42), script.eval());
        assertEquals(Integer.valueOf(42), script.eval());
    }
View Full Code Here

Examples of net.sourceforge.processdash.data.compiler.CompiledScript

        else if (arguments.size() > 2)
            result = arguments.get(2);

        if (result instanceof CompiledScript) {
            try {
                CompiledScript script = (CompiledScript) result;
                ListStack stack = new ListStack();
                script.run(stack, context);
                result = stack.pop();
            } catch (Exception e) {}
        }

        return result;
View Full Code Here

Examples of net.sourceforge.processdash.data.compiler.CompiledScript

        this.tag = tag;
    }

    public SearchFunction buildFor(String name, DataRepository data,
                                   String prefix) {
        CompiledScript script = null;
        if (expression != null) try {
            // normalize "unvarying" references - that is,
            // references marked with braces like [{this}]
            PValue expr = (PValue) expression.clone();
            expr.apply(new NormalizeReferences(data, prefix));
View Full Code Here

Examples of net.sourceforge.processdash.data.compiler.CompiledScript

     *
     * This method <b>must</b> be thread-safe.
     */
    public Object call(List arguments, ExpressionContext context)
    {
        CompiledScript script = null;
        try {
            script = (CompiledScript) arguments.get(0);
        } catch (ClassCastException cce) { }
        if (script == null) return null;

        ListData result = new ListData();
        LocalExpressionContext lContext = new LocalExpressionContext(context);
        ListStack stack = new ListStack();
        Iterator i = collapseLists(arguments, 1).iterator();
        Object item;
        while (i.hasNext()) try {
            lContext.setLocalValue(item = i.next());
            stack.clear();
            script.run(stack, lContext);
            handleItem(result, item, stack.pop());
        } catch (Exception e) {}
        return result;
    }
View Full Code Here

Examples of net.sourceforge.processdash.data.compiler.CompiledScript

      }

      /** Process a new style declaration. */
      public void caseANewStyleDeclaration(ANewStyleDeclaration node) {
        String name = Compiler.trimDelim(node.getIdentifier());
        CompiledScript script = null;
        try {
          script = Compiler.compile(node.getValue());
        } catch (CompilationException ce) {
          logger.severe("When parsing value for data element '" + name
                  + "', encountered error: " + ce.getMessage());
          putVal(name, new MalformedData(null));
          return;
        }
        if (!script.isConstant())
          putVal(name, script);
        else {
          SimpleData constant = script.getConstant();
          if (constant != null &&
              node.getAssignop() instanceof AReadOnlyAssignop)
            constant = (SimpleData) constant.getEditable(false);
          putVal(name, constant);
        }
View Full Code Here

Examples of net.sourceforge.processdash.data.compiler.CompiledScript

        for (Iterator iter = arguments.iterator(); iter.hasNext();) {
            Object arg = iter.next();

            if (arg instanceof CompiledScript) {
                try {
                    CompiledScript script = (CompiledScript) arg;
                    if (stack == null)
                        stack = new ListStack();
                    else
                        stack.clear();
                    script.run(stack, context);
                    arg = stack.pop();
                } catch (Exception e) {}
            }

            if (arg instanceof SimpleData
View Full Code Here

Examples of net.sourceforge.processdash.data.compiler.CompiledScript

        if (expression == null || expression.length() == 0)
            return null;

        String prefix = asString(getArg(arguments, 1));

        CompiledScript script = Compiler.compile(expression);

        try {
            Stack stack = new ListStack();
            if (prefix != null)
                context = new RelativeExpressionContext(context, prefix);
            script.run(stack, context);
            return stack.pop();
        } catch (ExecutionException ee) {
            return null;
        }
    }
View Full Code Here

Examples of org.elasticsearch.script.CompiledScript

                    vars);
            localVars.put("container",
                    SingletonS2ContainerFactory.getContainer());
            localVars.put("settings", settings);
            try {
                final CompiledScript compiledScript = scriptService.compile(
                        lang, script, scriptType);
                ExecutableScript executable = scriptService.executable(
                        compiledScript, localVars);
                Object result = executable.run();
                logger.info("[{}] \"{}\" => {}", target, script, result);
View Full Code Here

Examples of org.elasticsearch.script.CompiledScript

            scriptType = ScriptType.INDEXED;
        } else {
            scriptType = ScriptType.INLINE;
        }
        final ScriptService scriptService = riverConfig.getScriptService();
        final CompiledScript compiledScript = scriptService.compile(lang,
                script, scriptType);
        ExecutableScript executable = scriptService.executable(compiledScript,
                vars);
        return executable.run();
    }
View Full Code Here

Examples of pspdash.data.compiler.CompiledScript

      }

      /** Process a new style declaration. */
      public void caseANewStyleDeclaration(ANewStyleDeclaration node) {
        String name = Compiler.trimDelim(node.getIdentifier());
        CompiledScript script = null;
        try {
          script = Compiler.compile(node.getValue());
        } catch (CompilationException ce) {
          throw new LoadingException
            (new InvalidDatafileFormat(ce.getMessage()));
        }
        if (!script.isConstant())
          putVal(name, script);
        else {
          SimpleData constant = script.getConstant();
          if (constant != null &&
              node.getAssignop() instanceof AReadOnlyAssignop)
            constant = (SimpleData) constant.getEditable(false);
          putVal(name, constant);
        }
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.