use of org.kie.dmn.feel.lang.ast.TemporalConstantNode in project drools by kiegroup.
the class ASTCompilerVisitor method visit.
@Override
public DirectCompilerResult visit(FunctionInvocationNode n) {
TemporalConstantNode tcFolded = n.getTcFolded();
if (tcFolded != null) {
return replaceWithTemporalConstant(n, tcFolded);
}
DirectCompilerResult functionName = n.getName().accept(this);
DirectCompilerResult params = n.getParams().accept(this);
return DirectCompilerResult.of(Expressions.invoke(functionName.getExpression(), params.getExpression()), functionName.resultType).withFD(functionName).withFD(params);
}
use of org.kie.dmn.feel.lang.ast.TemporalConstantNode in project drools by kiegroup.
the class ASTTemporalConstantVisitor method visit.
@Override
public ASTNode visit(FunctionInvocationNode n) {
Optional<FEELFunction> fnOpt = Optional.empty();
if (n.getName() instanceof NameRefNode) {
// simple name
fnOpt = scopeHelper.resolve(n.getName().getText());
} else if (n.getName() instanceof QualifiedNameNode) {
QualifiedNameNode qnn = (QualifiedNameNode) n.getName();
String[] qns = qnn.getPartsAsStringArray();
String qn = Stream.of(qns).collect(Collectors.joining(" "));
fnOpt = scopeHelper.resolve(qn);
}
if (fnOpt.isPresent()) {
FEELFunction fn = fnOpt.get();
if (TEMPORAL_FNS.contains(fn)) {
try {
TemporalConstantNode tcNode = buildTemporalConstantNode(n, fn);
n.setTcFolded(tcNode);
} catch (Exception e) {
// temporal constant inlining failed, not an issue, simply not memoized.
}
}
}
return super.visit(n);
}
Aggregations