Search in sources :

Example 1 with Stack

use of net.sourceforge.processdash.data.compiler.Stack in project processdash by dtuma.

the class Eval method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    String expression = asString(getArg(arguments, 0));
    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;
    }
}
Also used : CompiledScript(net.sourceforge.processdash.data.compiler.CompiledScript) RelativeExpressionContext(net.sourceforge.processdash.data.compiler.RelativeExpressionContext) ListStack(net.sourceforge.processdash.data.compiler.ListStack) ExecutionException(net.sourceforge.processdash.data.compiler.ExecutionException) Stack(net.sourceforge.processdash.data.compiler.Stack) ListStack(net.sourceforge.processdash.data.compiler.ListStack)

Aggregations

CompiledScript (net.sourceforge.processdash.data.compiler.CompiledScript)1 ExecutionException (net.sourceforge.processdash.data.compiler.ExecutionException)1 ListStack (net.sourceforge.processdash.data.compiler.ListStack)1 RelativeExpressionContext (net.sourceforge.processdash.data.compiler.RelativeExpressionContext)1 Stack (net.sourceforge.processdash.data.compiler.Stack)1