@Override public EvalNode bind(EvalContext evalContext, Schema schema) { super.bind(evalContext, schema); try { if (evalContext != null && evalContext.hasScriptEngine(this)) { this.invokeContext.setScriptEngine(evalContext.getScriptEngine(this)); this.invokeContext.getScriptEngine().setFirstPhase(firstPhase); this.invokeContext.getScriptEngine().setLastPhase(lastPhase); } this.functionInvoke.init(invokeContext); } catch (IOException e) { throw new RuntimeException(e); } return this; }
@Override public EvalNode bind(EvalContext evalContext, Schema schema) { super.bind(evalContext, schema); try { if (evalContext != null && evalContext.hasScriptEngine(this)) { this.invokeContext.setScriptEngine(evalContext.getScriptEngine(this)); this.invokeContext.getScriptEngine().setFirstPhase(firstPhase); this.invokeContext.getScriptEngine().setLastPhase(lastPhase); } this.functionInvoke.init(invokeContext); } catch (IOException e) { throw new RuntimeException(e); } return this; }
@Override public EvalNode bind(EvalContext evalContext, Schema schema) { super.bind(evalContext, schema); try { this.funcInvoke = FunctionInvoke.newInstance(funcDesc); if (evalContext != null) { if (evalContext.hasScriptEngine(this)) { this.invokeContext.setScriptEngine(evalContext.getScriptEngine(this)); } if (evalContext.hasTimeZone()) { this.invokeContext.setTimeZone(evalContext.getTimeZone()); } } this.funcInvoke.init(invokeContext); } catch (IOException e) { throw new RuntimeException(e); } return this; }
@Override public EvalNode bind(EvalContext evalContext, Schema schema) { super.bind(evalContext, schema); try { this.funcInvoke = FunctionInvoke.newInstance(funcDesc); if (evalContext != null) { if (evalContext.hasScriptEngine(this)) { this.invokeContext.setScriptEngine(evalContext.getScriptEngine(this)); } if (evalContext.hasTimeZone()) { this.invokeContext.setTimeZone(evalContext.getTimeZone()); } } this.funcInvoke.init(invokeContext); } catch (IOException e) { throw new RuntimeException(e); } return this; }
@Override public EvalNode visitFuncCall(Object context, FunctionEval evalNode, Stack<EvalNode> stack) { boolean constantOfAllDescendents = true; if ("sleep".equals(evalNode.funcDesc.getFunctionName())) { constantOfAllDescendents = false; } else { if (evalNode.getArgs() != null) { for (EvalNode arg : evalNode.getArgs()) { arg = visit(context, arg, stack); constantOfAllDescendents &= (arg.getType() == EvalType.CONST); } } } if (constantOfAllDescendents && evalNode.getType() == EvalType.FUNCTION) { return new ConstEval(evalNode.bind(null, null).eval(null)); } else { return evalNode; } } }
@Override public EvalNode visitFuncCall(Object context, FunctionEval evalNode, Stack<EvalNode> stack) { boolean constantOfAllDescendents = true; if ("sleep".equals(evalNode.funcDesc.getFunctionName())) { constantOfAllDescendents = false; } else { if (evalNode.getArgs() != null) { for (EvalNode arg : evalNode.getArgs()) { arg = visit(context, arg, stack); constantOfAllDescendents &= (arg.getType() == EvalType.CONST); } } } if (constantOfAllDescendents && evalNode.getType() == EvalType.FUNCTION) { return new ConstEval(evalNode.bind(null, null).eval(null)); } else { return evalNode; } } }