Search in sources :

Example 6 with ListStack

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

the class Iff method call.

/** Perform a procedure call.
     *
     * This method <b>must</b> be thread-safe.
     */
public Object call(List arguments, ExpressionContext context) {
    if (arguments.size() < 2)
        return null;
    SimpleData test = getArg(arguments, 0);
    Object result = null;
    if (test != null && test.test())
        result = arguments.get(1);
    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;
}
Also used : CompiledScript(net.sourceforge.processdash.data.compiler.CompiledScript) ListStack(net.sourceforge.processdash.data.compiler.ListStack) SimpleData(net.sourceforge.processdash.data.SimpleData)

Aggregations

ListStack (net.sourceforge.processdash.data.compiler.ListStack)6 SimpleData (net.sourceforge.processdash.data.SimpleData)4 CompiledScript (net.sourceforge.processdash.data.compiler.CompiledScript)4 Iterator (java.util.Iterator)2 ExecutionException (net.sourceforge.processdash.data.compiler.ExecutionException)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ListData (net.sourceforge.processdash.data.ListData)1 ExpressionContext (net.sourceforge.processdash.data.compiler.ExpressionContext)1 LocalExpressionContext (net.sourceforge.processdash.data.compiler.LocalExpressionContext)1 RelativeExpressionContext (net.sourceforge.processdash.data.compiler.RelativeExpressionContext)1 Stack (net.sourceforge.processdash.data.compiler.Stack)1 LightweightSet (net.sourceforge.processdash.util.LightweightSet)1 LightweightSynchronizedSet (net.sourceforge.processdash.util.LightweightSynchronizedSet)1