use of org.wso2.ballerinalang.compiler.tree.expressions.BLangUnaryExpr in project ballerina by ballerina-lang.
the class IterableCodeDesugar method generateFilter.
/**
* Generates statements for filter operation.
*
* if(!lambda(...)){
* next;
* }
*
* @param blockStmt target
* @param operation operation instance
*/
private void generateFilter(BLangBlockStmt blockStmt, Operation operation) {
final DiagnosticPos pos = operation.pos;
final BLangIf ifNode = ASTBuilderUtil.createIfStmt(pos, blockStmt);
final BLangUnaryExpr notExpr = (BLangUnaryExpr) TreeBuilder.createUnaryExpressionNode();
notExpr.pos = pos;
notExpr.operator = OperatorKind.NOT;
notExpr.opSymbol = (BOperatorSymbol) symResolver.resolveUnaryOperator(pos, notExpr.operator, symTable.booleanType);
notExpr.expr = ASTBuilderUtil.createInvocationExpr(pos, operation.lambdaSymbol, Lists.of(operation.argVar), symResolver);
notExpr.type = symTable.booleanType;
ifNode.expr = notExpr;
ifNode.body = ASTBuilderUtil.createBlockStmt(pos);
ASTBuilderUtil.createNextStmt(pos, ifNode.body);
}
Aggregations