Search in sources :

Example 1 with DirectCompilerResult.mergeFDs

use of org.kie.dmn.feel.codegen.feel11.DirectCompilerResult.mergeFDs in project drools by kiegroup.

the class ASTCompilerVisitor method visit.

@Override
public DirectCompilerResult visit(ContextNode n) {
    if (n.getEntries().isEmpty()) {
        return DirectCompilerResult.of(FeelCtx.emptyContext(), BuiltInType.CONTEXT);
    }
    scopeHelper.pushScope();
    // openContext(feelCtx)
    MapBackedType resultType = new MapBackedType();
    DirectCompilerResult openContext = DirectCompilerResult.of(FeelCtx.openContext(), resultType);
    // .setEntry( k,v )
    // .setEntry( k,v )
    // ...
    DirectCompilerResult entries = n.getEntries().stream().map(e -> {
        DirectCompilerResult r = e.accept(this);
        scopeHelper.addInScope(e.getName().getText(), r.resultType);
        return r;
    }).reduce(openContext, (l, r) -> DirectCompilerResult.of(r.getExpression().asMethodCallExpr().setScope(l.getExpression()), r.resultType, DirectCompilerResult.mergeFDs(l, r)));
    scopeHelper.popScope();
    // .closeContext()
    return DirectCompilerResult.of(FeelCtx.closeContext(entries), resultType, entries.getFieldDeclarations());
}
Also used : QuantifiedExpressionNode(org.kie.dmn.feel.lang.ast.QuantifiedExpressionNode) SimpleType(org.kie.dmn.feel.lang.SimpleType) Visitor(org.kie.dmn.feel.lang.ast.Visitor) ListNode(org.kie.dmn.feel.lang.ast.ListNode) ContextNode(org.kie.dmn.feel.lang.ast.ContextNode) FunctionInvocationNode(org.kie.dmn.feel.lang.ast.FunctionInvocationNode) NullLiteralExpr(com.github.javaparser.ast.expr.NullLiteralExpr) InNode(org.kie.dmn.feel.lang.ast.InNode) BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) Duration(java.time.Duration) Map(java.util.Map) Msg(org.kie.dmn.feel.util.Msg) NumberNode(org.kie.dmn.feel.lang.ast.NumberNode) Expression(com.github.javaparser.ast.expr.Expression) BinaryExpr(com.github.javaparser.ast.expr.BinaryExpr) ForExpressionNode(org.kie.dmn.feel.lang.ast.ForExpressionNode) IfExpressionNode(org.kie.dmn.feel.lang.ast.IfExpressionNode) UnknownType(com.github.javaparser.ast.type.UnknownType) DashNode(org.kie.dmn.feel.lang.ast.DashNode) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) BuiltInType(org.kie.dmn.feel.lang.types.BuiltInType) TypeNode(org.kie.dmn.feel.lang.ast.TypeNode) ASTNode(org.kie.dmn.feel.lang.ast.ASTNode) Collectors(java.util.stream.Collectors) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) EnclosedExpr(com.github.javaparser.ast.expr.EnclosedExpr) List(java.util.List) StaticJavaParser(com.github.javaparser.StaticJavaParser) InfixOpNode(org.kie.dmn.feel.lang.ast.InfixOpNode) QualifiedNameNode(org.kie.dmn.feel.lang.ast.QualifiedNameNode) Entry(java.util.Map.Entry) NullNode(org.kie.dmn.feel.lang.ast.NullNode) CTypeNode(org.kie.dmn.feel.lang.ast.CTypeNode) FieldAccessExpr(com.github.javaparser.ast.expr.FieldAccessExpr) FunctionTypeNode(org.kie.dmn.feel.lang.ast.FunctionTypeNode) ChronoPeriod(java.time.chrono.ChronoPeriod) FunctionDefNode(org.kie.dmn.feel.lang.ast.FunctionDefNode) EvalHelper(org.kie.dmn.feel.util.EvalHelper) ScopeHelper(org.kie.dmn.feel.parser.feel11.ScopeHelper) ContextEntryNode(org.kie.dmn.feel.lang.ast.ContextEntryNode) NamedParameterNode(org.kie.dmn.feel.lang.ast.NamedParameterNode) LambdaExpr(com.github.javaparser.ast.expr.LambdaExpr) NameRefNode(org.kie.dmn.feel.lang.ast.NameRefNode) MapBackedType(org.kie.dmn.feel.lang.impl.MapBackedType) ConditionalExpr(com.github.javaparser.ast.expr.ConditionalExpr) UnaryTestNode(org.kie.dmn.feel.lang.ast.UnaryTestNode) NameDefNode(org.kie.dmn.feel.lang.ast.NameDefNode) Parameter(com.github.javaparser.ast.body.Parameter) HashMap(java.util.HashMap) IterationContextNode(org.kie.dmn.feel.lang.ast.IterationContextNode) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CompositeType(org.kie.dmn.feel.lang.CompositeType) TemporalConstantNode(org.kie.dmn.feel.lang.ast.TemporalConstantNode) BooleanNode(org.kie.dmn.feel.lang.ast.BooleanNode) Type(org.kie.dmn.feel.lang.Type) AtLiteralNode(org.kie.dmn.feel.lang.ast.AtLiteralNode) ListTypeNode(org.kie.dmn.feel.lang.ast.ListTypeNode) BooleanLiteralExpr(com.github.javaparser.ast.expr.BooleanLiteralExpr) UnaryTestListNode(org.kie.dmn.feel.lang.ast.UnaryTestListNode) RangeNode(org.kie.dmn.feel.lang.ast.RangeNode) FormalParameterNode(org.kie.dmn.feel.lang.ast.FormalParameterNode) NameExpr(com.github.javaparser.ast.expr.NameExpr) PathExpressionNode(org.kie.dmn.feel.lang.ast.PathExpressionNode) FieldDeclaration(com.github.javaparser.ast.body.FieldDeclaration) DirectCompilerResult.mergeFDs(org.kie.dmn.feel.codegen.feel11.DirectCompilerResult.mergeFDs) SignedUnaryNode(org.kie.dmn.feel.lang.ast.SignedUnaryNode) TypeAndFn(org.kie.dmn.feel.lang.ast.AtLiteralNode.TypeAndFn) BetweenNode(org.kie.dmn.feel.lang.ast.BetweenNode) ContextTypeNode(org.kie.dmn.feel.lang.ast.ContextTypeNode) FilterExpressionNode(org.kie.dmn.feel.lang.ast.FilterExpressionNode) IntegerLiteralExpr(com.github.javaparser.ast.expr.IntegerLiteralExpr) InstanceOfNode(org.kie.dmn.feel.lang.ast.InstanceOfNode) StringNode(org.kie.dmn.feel.lang.ast.StringNode) MapBackedType(org.kie.dmn.feel.lang.impl.MapBackedType)

Aggregations

StaticJavaParser (com.github.javaparser.StaticJavaParser)1 FieldDeclaration (com.github.javaparser.ast.body.FieldDeclaration)1 Parameter (com.github.javaparser.ast.body.Parameter)1 BinaryExpr (com.github.javaparser.ast.expr.BinaryExpr)1 BooleanLiteralExpr (com.github.javaparser.ast.expr.BooleanLiteralExpr)1 ConditionalExpr (com.github.javaparser.ast.expr.ConditionalExpr)1 EnclosedExpr (com.github.javaparser.ast.expr.EnclosedExpr)1 Expression (com.github.javaparser.ast.expr.Expression)1 FieldAccessExpr (com.github.javaparser.ast.expr.FieldAccessExpr)1 IntegerLiteralExpr (com.github.javaparser.ast.expr.IntegerLiteralExpr)1 LambdaExpr (com.github.javaparser.ast.expr.LambdaExpr)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1 NameExpr (com.github.javaparser.ast.expr.NameExpr)1 NullLiteralExpr (com.github.javaparser.ast.expr.NullLiteralExpr)1 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 UnknownType (com.github.javaparser.ast.type.UnknownType)1 Duration (java.time.Duration)1 ChronoPeriod (java.time.chrono.ChronoPeriod)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1