Search in sources :

Example 61 with BLangBlockStmt

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

the class BLangPackageBuilder method addTimeoutCause.

public void addTimeoutCause(Set<Whitespace> ws, String identifier) {
    BLangForkJoin forkJoin = (BLangForkJoin) this.forkJoinNodesStack.peek();
    forkJoin.timeoutBody = (BLangBlockStmt) this.blockNodeStack.pop();
    forkJoin.timeoutExpression = (BLangExpression) this.exprNodeStack.pop();
    Set<Whitespace> varWS = removeNthFromLast(ws, 3);
    forkJoin.addWS(ws);
    forkJoin.timeoutVariable = (BLangVariable) this.generateBasicVarNode((DiagnosticPos) this.typeNodeStack.peek().getPosition(), varWS, identifier, false);
}
Also used : BLangForkJoin(org.wso2.ballerinalang.compiler.tree.statements.BLangForkJoin) Whitespace(org.ballerinalang.model.Whitespace)

Example 62 with BLangBlockStmt

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

the class BLangPackageBuilder method addTransactionBlock.

public void addTransactionBlock(DiagnosticPos pos) {
    TransactionNode transactionNode = transactionNodeStack.peek();
    BLangBlockStmt transactionBlock = (BLangBlockStmt) this.blockNodeStack.pop();
    transactionBlock.pos = pos;
    transactionNode.setTransactionBody(transactionBlock);
}
Also used : BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) TransactionNode(org.ballerinalang.model.tree.statements.TransactionNode)

Example 63 with BLangBlockStmt

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

the class BLangPackageBuilder method addMatchStmtPattern.

public void addMatchStmtPattern(DiagnosticPos pos, Set<Whitespace> ws, String identifier) {
    BLangMatchStmtPatternClause patternClause = (BLangMatchStmtPatternClause) TreeBuilder.createMatchStatementPattern();
    patternClause.pos = pos;
    Set<Whitespace> varDefWS = removeNthFromStart(ws, 0);
    patternClause.addWS(ws);
    // Create a variable node
    identifier = identifier == null ? Names.IGNORE.value : identifier;
    BLangVariable var = (BLangVariable) TreeBuilder.createVariableNode();
    var.pos = pos;
    var.setName(this.createIdentifier(identifier));
    var.setTypeNode(this.typeNodeStack.pop());
    var.addWS(varDefWS);
    patternClause.variable = var;
    patternClause.body = (BLangBlockStmt) blockNodeStack.pop();
    patternClause.body.pos = pos;
    this.matchStmtStack.peekFirst().patternClauses.add(patternClause);
}
Also used : BLangMatchStmtPatternClause(org.wso2.ballerinalang.compiler.tree.statements.BLangMatch.BLangMatchStmtPatternClause) Whitespace(org.ballerinalang.model.Whitespace) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 64 with BLangBlockStmt

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

the class BLangPackageBuilder method addForeachStatement.

public void addForeachStatement(DiagnosticPos pos, Set<Whitespace> ws) {
    BLangForeach foreach = (BLangForeach) TreeBuilder.createForeachNode();
    foreach.addWS(ws);
    foreach.pos = pos;
    foreach.setCollection(exprNodeStack.pop());
    foreach.addWS(commaWsStack.pop());
    List<ExpressionNode> lExprList = exprNodeListStack.pop();
    lExprList.forEach(expressionNode -> foreach.addVariable((BLangVariableReference) expressionNode));
    BLangBlockStmt foreachBlock = (BLangBlockStmt) this.blockNodeStack.pop();
    foreachBlock.pos = pos;
    foreach.setBody(foreachBlock);
    addStmtToCurrentBlock(foreach);
}
Also used : BLangForeach(org.wso2.ballerinalang.compiler.tree.statements.BLangForeach) BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangVariableReference(org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)

Example 65 with BLangBlockStmt

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

the class BLangPackageBuilder method addOnretryBlock.

public void addOnretryBlock(DiagnosticPos pos, Set<Whitespace> ws) {
    TransactionNode transactionNode = transactionNodeStack.peek();
    BLangBlockStmt onretryBlock = (BLangBlockStmt) this.blockNodeStack.pop();
    onretryBlock.pos = pos;
    transactionNode.addWS(ws);
    transactionNode.setOnRetryBody(onretryBlock);
}
Also used : BLangBlockStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt) TransactionNode(org.ballerinalang.model.tree.statements.TransactionNode)

Aggregations

BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)33 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)22 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)19 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)16 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)12 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)9 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)8 BLangIf (org.wso2.ballerinalang.compiler.tree.statements.BLangIf)8 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)7 BLangBinaryExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr)6 BLangIndexBasedAccess (org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess)6 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)6 BLangReturn (org.wso2.ballerinalang.compiler.tree.statements.BLangReturn)6 Name (org.wso2.ballerinalang.compiler.util.Name)6 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)5 BLangMatchStmtPatternClause (org.wso2.ballerinalang.compiler.tree.statements.BLangMatch.BLangMatchStmtPatternClause)5 ArrayList (java.util.ArrayList)4 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)4 BLangForeach (org.wso2.ballerinalang.compiler.tree.statements.BLangForeach)4 Whitespace (org.ballerinalang.model.Whitespace)3