Search in sources :

Example 1 with FunctionTypeNode

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

the class ASTCompilerVisitor method visit.

@Override
public DirectCompilerResult visit(FunctionTypeNode n) {
    List<DirectCompilerResult> args = new ArrayList<>();
    for (TypeNode arg : n.getArgTypes()) {
        args.add(arg.accept(this));
    }
    DirectCompilerResult ret = n.getRetType().accept(this);
    return DirectCompilerResult.of(Expressions.genFnType(args.stream().map(DirectCompilerResult::getExpression).collect(Collectors.toList()), ret.getExpression()), BuiltInType.UNKNOWN, mergeFDs(args)).withFD(ret);
}
Also used : ArrayList(java.util.ArrayList) TypeNode(org.kie.dmn.feel.lang.ast.TypeNode) CTypeNode(org.kie.dmn.feel.lang.ast.CTypeNode) FunctionTypeNode(org.kie.dmn.feel.lang.ast.FunctionTypeNode) ListTypeNode(org.kie.dmn.feel.lang.ast.ListTypeNode) ContextTypeNode(org.kie.dmn.feel.lang.ast.ContextTypeNode)

Example 2 with FunctionTypeNode

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

the class ASTBuilderVisitor method visitFunctionType.

@Override
public BaseNode visitFunctionType(FEEL_1_1Parser.FunctionTypeContext ctx) {
    List<TypeNode> argTypes = new ArrayList<>();
    for (TypeContext t : ctx.type()) {
        argTypes.add((TypeNode) visit(t));
    }
    TypeNode type = argTypes.remove(argTypes.size() - 1);
    return new FunctionTypeNode(ctx, argTypes, type);
}
Also used : FunctionTypeNode(org.kie.dmn.feel.lang.ast.FunctionTypeNode) ArrayList(java.util.ArrayList) ListTypeNode(org.kie.dmn.feel.lang.ast.ListTypeNode) TypeNode(org.kie.dmn.feel.lang.ast.TypeNode) ContextTypeNode(org.kie.dmn.feel.lang.ast.ContextTypeNode) FunctionTypeNode(org.kie.dmn.feel.lang.ast.FunctionTypeNode) TypeContext(org.kie.dmn.feel.parser.feel11.FEEL_1_1Parser.TypeContext)

Aggregations

ArrayList (java.util.ArrayList)2 ContextTypeNode (org.kie.dmn.feel.lang.ast.ContextTypeNode)2 FunctionTypeNode (org.kie.dmn.feel.lang.ast.FunctionTypeNode)2 ListTypeNode (org.kie.dmn.feel.lang.ast.ListTypeNode)2 TypeNode (org.kie.dmn.feel.lang.ast.TypeNode)2 CTypeNode (org.kie.dmn.feel.lang.ast.CTypeNode)1 TypeContext (org.kie.dmn.feel.parser.feel11.FEEL_1_1Parser.TypeContext)1