public CompilationUnit getSourceCode() { DirectCompilerResult compilerResult = getCompilerResult(); return compiler.getCompilationUnit( CompiledFEELUnaryTests.class, TEMPLATE_RESOURCE, packageName, TEMPLATE_CLASS, expression, compilerResult.getExpression(), compilerResult.getFieldDeclarations()); }
public CompilationUnit getSourceCode() { DirectCompilerResult compilerResult = getCompilerResult(); return compiler.getCompilationUnit( CompiledFEELExpression.class, TEMPLATE_RESOURCE, packageName, TEMPLATE_CLASS, expression, compilerResult.getExpression(), compilerResult.getFieldDeclarations()); }
@Override public DirectCompilerResult visit(FilterExpressionNode n) { DirectCompilerResult expr = n.getExpression().accept(this); DirectCompilerResult filter = n.getFilter().accept(this); Expressions.NamedLambda lambda = Expressions.namedLambda(filter.getExpression(), n.getFilter().getText()); DirectCompilerResult r = DirectCompilerResult.of( Expressions.filter(expr.getExpression(), lambda.name()), // here we could still try to infer the result type, but presently use ANY BuiltInType.UNKNOWN).withFD(expr).withFD(filter); r.addFieldDesclaration(lambda.field()); return r; }
public String getSourceForUnaryTest(String packageName, String className, String feelExpression, DirectCompilerResult directResult) { return getSourceForUnaryTest(packageName, className, feelExpression, directResult.getExpression(), directResult.getFieldDeclarations()); }
/** * Generates a compilable class that reports a (compile-time) error at runtime */ public static CompiledFEELExpression compiledError(String expression, String msg) { return new CompilerBytecodeLoader() .makeFromJPExpression( expression, compiledErrorExpression(msg), Collections.emptySet()); }
@Override public DirectCompilerResult visitCondAnd(FEEL_1_1Parser.CondAndContext ctx) { DirectCompilerResult left = visit( ctx.left ); DirectCompilerResult right = visit( ctx.right ); MethodCallExpr result = new MethodCallExpr(null, "and"); result.addArgument(left.getExpression()); result.addArgument(right.getExpression()); return DirectCompilerResult.of(result, BuiltInType.BOOLEAN).withFD(left).withFD(right); }
public static NamedLambda namedLambda(Expression expr, String text) { LambdaExpr lambda = Expressions.lambda(expr); String name = Constants.functionName(text); FieldDeclaration field = Constants.function(name, lambda); return new NamedLambda(new NameExpr(name), lambda, field); }
public static NamedLambda namedUnaryLambda(Expression expr, String text) { LambdaExpr lambda = Expressions.unaryLambda(expr); String name = Constants.unaryTestName(text); FieldDeclaration field = Constants.unaryTest(name, lambda); return new NamedLambda(new NameExpr(name), lambda, field); }
private Object parseCompileEvaluate(String feelLiteralExpression) { CompiledFEELExpression compiledExpression = parse( feelLiteralExpression ); LOG.debug("{}", compiledExpression); EvaluationContext emptyContext = CodegenTestUtil.newEmptyEvaluationContext(); Object result = compiledExpression.apply(emptyContext); LOG.debug("{}", result); return result; }
@Override public CompiledExpression compile(String expression, CompilerContext ctx) { return new ProcessedExpression( expression, ctx, ProcessedFEELUnit.DefaultMode.of(doCompile || ctx.isDoCompile()), profiles).getResult(); }
public CompilationUnit generateExpressionSource(String expression, CompilerContext ctx) { return new ProcessedExpression( expression, ctx, ProcessedFEELUnit.DefaultMode.of(doCompile || ctx.isDoCompile()), profiles).getSourceCode(); }
@Override public Object apply(EvaluationContext evaluationContext) { return defaultResult.apply(evaluationContext); } }
public UnaryTestCompiledExecutableExpression getCompiled() { CompiledFEELUnaryTests compiledFEELExpression = compiler.compileUnit( packageName, TEMPLATE_CLASS, getSourceCode()); return new UnaryTestCompiledExecutableExpression(compiledFEELExpression); }
public CompiledExecutableExpression getCompiled() { CompiledFEELExpression compiledFEELExpression = compiler.compileUnit( packageName, TEMPLATE_CLASS, getSourceCode()); return new CompiledExecutableExpression(compiledFEELExpression); }
@Override public String toString() { return "function "+getSignature(); } }
@Override public DirectCompilerResult visitExpressionTextual(FEEL_1_1Parser.ExpressionTextualContext ctx) { DirectCompilerResult expr = visit( ctx.expr ); return expr; }
@Override public Object apply(EvaluationContext evaluationContext) { return expr.apply(evaluationContext); } }