use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addLockStmt.
public void addLockStmt(DiagnosticPos pos, Set<Whitespace> ws) {
BLangLock lockNode = (BLangLock) TreeBuilder.createLockNode();
lockNode.pos = pos;
lockNode.addWS(ws);
BLangBlockStmt lockBlock = (BLangBlockStmt) this.blockNodeStack.pop();
lockBlock.pos = pos;
lockNode.setBody(lockBlock);
addStmtToCurrentBlock(lockNode);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addCatchClause.
public void addCatchClause(DiagnosticPos poc, Set<Whitespace> ws, String paramName) {
BLangVariable variableNode = (BLangVariable) TreeBuilder.createVariableNode();
variableNode.typeNode = (BLangType) this.typeNodeStack.pop();
variableNode.name = (BLangIdentifier) createIdentifier(paramName);
variableNode.pos = variableNode.typeNode.pos;
variableNode.addWS(removeNthFromLast(ws, 3));
BLangCatch catchNode = (BLangCatch) TreeBuilder.createCatchNode();
catchNode.pos = poc;
catchNode.addWS(ws);
catchNode.body = (BLangBlockStmt) this.blockNodeStack.pop();
catchNode.param = variableNode;
tryCatchFinallyNodesStack.peek().catchBlocks.add(catchNode);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addWhileStmt.
public void addWhileStmt(DiagnosticPos pos, Set<Whitespace> ws) {
BLangWhile whileNode = (BLangWhile) TreeBuilder.createWhileNode();
whileNode.setCondition(exprNodeStack.pop());
whileNode.pos = pos;
whileNode.addWS(ws);
BLangBlockStmt whileBlock = (BLangBlockStmt) this.blockNodeStack.pop();
whileBlock.pos = pos;
whileNode.setBody(whileBlock);
addStmtToCurrentBlock(whileNode);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addJoinCause.
public void addJoinCause(Set<Whitespace> ws, String identifier) {
BLangForkJoin forkJoin = (BLangForkJoin) this.forkJoinNodesStack.peek();
forkJoin.joinedBody = (BLangBlockStmt) this.blockNodeStack.pop();
Set<Whitespace> varWS = removeNthFromLast(ws, 3);
forkJoin.addWS(ws);
forkJoin.joinResultVar = (BLangVariable) this.generateBasicVarNode((DiagnosticPos) this.typeNodeStack.peek().getPosition(), varWS, identifier, false);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class TreeVisitor method visit.
@Override
public void visit(BLangForkJoin forkJoin) {
SymbolEnv folkJoinEnv = SymbolEnv.createFolkJoinEnv(forkJoin, this.symbolEnv);
// TODO: check the symbolEnter.defineNode
forkJoin.workers.forEach(e -> this.symbolEnter.defineNode(e, folkJoinEnv));
forkJoin.workers.forEach(e -> this.acceptNode(e, folkJoinEnv));
// if (!this.isJoinResultType(forkJoin.joinResultVar)) {
// this.dlog.error(forkJoin.joinResultVar.pos, DiagnosticCode.INVALID_WORKER_JOIN_RESULT_TYPE);
// }
/* create code black and environment for join result section, i.e. (map results) */
BLangBlockStmt joinResultsBlock = this.generateCodeBlock(this.createVarDef(forkJoin.joinResultVar));
SymbolEnv joinResultsEnv = SymbolEnv.createBlockEnv(joinResultsBlock, this.symbolEnv);
this.acceptNode(joinResultsBlock, joinResultsEnv);
/* create an environment for the join body, making the enclosing environment the earlier
* join result's environment */
SymbolEnv joinBodyEnv = SymbolEnv.createBlockEnv(forkJoin.joinedBody, joinResultsEnv);
this.acceptNode(forkJoin.joinedBody, joinBodyEnv);
if (forkJoin.timeoutExpression != null) {
/* create code black and environment for timeout section */
BLangBlockStmt timeoutVarBlock = this.generateCodeBlock(this.createVarDef(forkJoin.timeoutVariable));
SymbolEnv timeoutVarEnv = SymbolEnv.createBlockEnv(timeoutVarBlock, this.symbolEnv);
this.acceptNode(timeoutVarBlock, timeoutVarEnv);
/* create an environment for the timeout body, making the enclosing environment the earlier
* timeout var's environment */
SymbolEnv timeoutBodyEnv = SymbolEnv.createBlockEnv(forkJoin.timeoutBody, timeoutVarEnv);
this.acceptNode(forkJoin.timeoutBody, timeoutBodyEnv);
}
}
Aggregations