Search in sources :

Example 1 with FormalParameterNode

use of org.kie.dmn.feel.lang.ast.FormalParameterNode in project drools by kiegroup.

the class ASTCompilerVisitor method visit.

@Override
public DirectCompilerResult visit(FunctionDefNode n) {
    MethodCallExpr list = Expressions.list();
    n.getFormalParameters().stream().map(fp -> fp.accept(this)).map(DirectCompilerResult::getExpression).forEach(list::addArgument);
    if (n.isExternal()) {
        List<String> paramNames = n.getFormalParameters().stream().map(FormalParameterNode::getName).map(BaseNode::getText).collect(Collectors.toList());
        return Functions.declaration(n, list, Functions.external(paramNames, n.getBody()));
    } else {
        DirectCompilerResult body = n.getBody().accept(this);
        return Functions.declaration(n, list, body.getExpression()).withFD(body);
    }
}
Also used : FormalParameterNode(org.kie.dmn.feel.lang.ast.FormalParameterNode) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr)

Example 2 with FormalParameterNode

use of org.kie.dmn.feel.lang.ast.FormalParameterNode in project drools by kiegroup.

the class ASTTemporalConstantVisitor method visit.

@Override
public ASTNode visit(FunctionDefNode n) {
    scopeHelper.pushScope();
    for (FormalParameterNode fp : n.getFormalParameters()) {
        scopeHelper.addInScope(EvalHelper.normalizeVariableName(fp.getName().getText()), MASKED);
    }
    n.getBody().accept(this);
    scopeHelper.popScope();
    return n;
}
Also used : FormalParameterNode(org.kie.dmn.feel.lang.ast.FormalParameterNode)

Aggregations

FormalParameterNode (org.kie.dmn.feel.lang.ast.FormalParameterNode)2 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1