protected static NodeValue eval(Binding binding, FunctionEnv funcEnv, Expr expr) { if ( expr == null ) return null ; return expr.eval(binding, funcEnv) ; }
@Override public NodeValue evalSpecial(Binding binding, FunctionEnv env) { try { expr.eval(binding, env) ; return NodeValue.TRUE ; } catch (VariableNotBoundException ex) { return NodeValue.FALSE ; } }
protected static NodeValue eval(Binding binding, FunctionEnv funcEnv, Expr expr) { if ( expr == null ) return null ; return expr.eval(binding, funcEnv) ; }
@Override public NodeValue evalSpecial(Binding binding, FunctionEnv env) { try { expr.eval(binding, env) ; return NodeValue.TRUE ; } catch (VariableNotBoundException ex) { return NodeValue.FALSE ; } }
/** * Executes the function */ @Override public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) { //Evaluate the actual expression return this.actualExpr.eval(binding, env); }
/** Special form evaluation (example, don't eval the arguments first) */ @Override protected NodeValue evalSpecial(Binding binding, FunctionEnv env) { NodeValue nv = condition.eval(binding, env) ; if ( condition.isSatisfied(binding, env) ) return thenExpr.eval(binding, env) ; else return elseExpr.eval(binding, env) ; }
/** Special form evaluation (example, don't eval the arguments first) */ @Override protected NodeValue evalSpecial(Binding binding, FunctionEnv env) { NodeValue nv = condition.eval(binding, env) ; if ( condition.isSatisfied(binding, env) ) return thenExpr.eval(binding, env) ; else return elseExpr.eval(binding, env) ; }
@Override final public void accumulate(Binding binding, FunctionEnv functionEnv) { try { NodeValue nv = expr.eval(binding, functionEnv) ; if ( values.contains(nv) ) return ; values.add(nv) ; accumulateDistinct(nv, binding, functionEnv) ; count++ ; } catch (ExprEvalException ex) { errorCount++ ; accumulateError(binding, functionEnv) ; } }
public Node get(Var var, Binding binding, FunctionEnv funcEnv) { Expr expr = exprs.get(var) ; if ( expr == null ) return binding.get(var) ; try { NodeValue nv = expr.eval(binding, funcEnv) ; if ( nv == null ) return null ; return nv.asNode() ; } catch (ExprEvalException ex) //{ Log.warn(this, "Eval failure "+expr+": "+ex.getMessage()) ; } { } return null ; }
final public void accumulate(Binding binding, FunctionEnv functionEnv) { try { NodeValue nv = expr.eval(binding, functionEnv) ; if ( values.contains(nv) ) return ; values.add(nv) ; accumulateDistinct(nv, binding, functionEnv) ; count++ ; } catch (ExprEvalException ex) { errorCount++ ; accumulateError(binding, functionEnv) ; } }
@Override public NodeValue evalSpecial(Binding binding, FunctionEnv env) { for ( Expr expr : super.getArgs() ) { try { NodeValue nv = expr.eval(binding, env) ; return nv ; } catch (ExprEvalException ex) {} } throw new ExprEvalException("COALESCE: no value") ; }
public Node get(Var var, Binding binding, FunctionEnv funcEnv) { Expr expr = exprs.get(var) ; if ( expr == null ) return binding.get(var) ; try { NodeValue nv = expr.eval(binding, funcEnv) ; if ( nv == null ) return null ; return nv.asNode() ; } catch (ExprEvalException ex) //{ Log.warn(this, "Eval failure "+expr+": "+ex.getMessage()) ; } { } return null ; }
@Override public NodeValue evalSpecial(Binding binding, FunctionEnv env) { for ( Expr expr : super.getArgs() ) { try { NodeValue nv = expr.eval(binding, env) ; return nv ; } catch (ExprEvalException ex) {} } throw new ExprEvalException("COALESCE: no value") ; }
final public void accumulate(Binding binding, FunctionEnv functionEnv) { try { NodeValue nv = expr.eval(binding, functionEnv) ; accumulate(nv, binding, functionEnv) ; count++ ; } catch (ExprEvalException ex) { errorCount++ ; accumulateError(binding, functionEnv) ; } }
@Override final public void accumulate(Binding binding, FunctionEnv functionEnv) { try { NodeValue nv = expr.eval(binding, functionEnv) ; accumulate(nv, binding, functionEnv) ; count++ ; } catch (ExprEvalException ex) { errorCount++ ; accumulateError(binding, functionEnv) ; } }
public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) { // This is merely to allow functions to be // It duplicates code in E_Function/ExprFunctionN. this.env = env ; if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("FunctionBase: Null args list") ; List<NodeValue> evalArgs = new ArrayList<NodeValue>() ; for ( Iterator<Expr> iter = args.iterator() ; iter.hasNext() ; ) { Expr e = iter.next() ; NodeValue x = e.eval(binding, env) ; evalArgs.add(x) ; } NodeValue nv = exec(evalArgs) ; arguments = null ; return nv ; }
public static NodeValue eval(Expr expr, Binding binding) { Context context = ARQ.getContext().copy() ; context.set(ARQConstants.sysCurrentTime, NodeFactory.nowAsDateTime()) ; FunctionEnv env = new ExecutionContext(context, null, null, null) ; NodeValue r = expr.eval(binding, env) ; return r ; }
@Override public NodeValue eval(List<NodeValue> args, FunctionEnv env) { // Instead of evalSpecial, we can rely on the machinery to evaluate the arguments to CALL first. // This precludes special forms for CALL first argument. // This code here is not usually called - evalSpecial is more general and is the main code path, NodeValue func = args.get(0) ; if (func == null) throw new ExprEvalException("CALL: Function identifier unbound"); if (func.isIRI()) { ExprList a = new ExprList() ; for ( int i = 1 ; i < args.size() ; i++ ) a.add(args.get(i)) ; //Expr e = null ; Expr e = new E_Function(func.getNode().getURI(), a); //Calling this may throw an error which we will just let bubble up return e.eval(null, env) ; } else throw new ExprEvalException("CALL: Function identifier not an IRI"); }
public static NodeValue eval(Expr expr, Binding binding) { Context context = ARQ.getContext().copy() ; context.set(ARQConstants.sysCurrentTime, NodeFactoryExtra.nowAsDateTime()) ; FunctionEnv env = new ExecutionContext(context, null, null, null) ; NodeValue r = expr.eval(binding, env) ; return r ; }
/** Processes unevaluated arguments */ @Override public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) { if ( args == null ) // The contract on the function interface is that this should not happen. throw new ARQInternalErrorException("function eval: Null args list") ; if ( args.size() != 1 ) throw new ARQInternalErrorException("function eval: Arg list not of size 1") ; Expr ex = args.get(0) ; try { NodeValue v = ex.eval(binding, env) ; return v ; } catch (ExprEvalException evalEx) { return NodeValue.FALSE ; } }