Search in sources :

Example 11 with BLangExpressionStmt

use of org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt in project ballerina by ballerina-lang.

the class IterableCodeDesugar method generateForeach.

/**
 * Generates statements for foreach operation.
 *
 * lambda(...)
 *
 * @param blockStmt target
 * @param operation operation instance
 */
private void generateForeach(BLangBlockStmt blockStmt, Operation operation) {
    final DiagnosticPos pos = operation.pos;
    final BLangExpressionStmt exprStmt = ASTBuilderUtil.createExpressionStmt(pos, blockStmt);
    exprStmt.expr = ASTBuilderUtil.createInvocationExpr(pos, operation.lambdaSymbol, Lists.of(operation.argVar), symResolver);
}
Also used : DiagnosticPos(org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos) BLangExpressionStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)

Aggregations

BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)9 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)5 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)5 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)4 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)3 ArrayList (java.util.ArrayList)2 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)2 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)2 Name (org.wso2.ballerinalang.compiler.util.Name)2 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)1 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)1 BLangIdentifier (org.wso2.ballerinalang.compiler.tree.BLangIdentifier)1 BLangUnaryExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangUnaryExpr)1