use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class SignatureTreeVisitor method visit.
@Override
public void visit(BLangBlockStmt blockNode) {
SymbolEnv blockEnv = SymbolEnv.createBlockEnv(blockNode, symbolEnv);
blockNode.stmts.forEach(stmt -> this.acceptNode(stmt, blockEnv));
if (!terminateVisitor && this.isCursorWithinBlock()) {
Map<Name, Scope.ScopeEntry> visibleSymbolEntries = symbolResolver.getAllVisibleInScopeSymbols(blockEnv);
this.populateSymbols(visibleSymbolEntries);
}
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class SymbolEnter method addInitReturnStatement.
private void addInitReturnStatement(BLangBlockStmt bLangBlockStmt) {
// Add return statement to the init function
BLangReturn returnStmt = (BLangReturn) TreeBuilder.createReturnNode();
returnStmt.pos = bLangBlockStmt.pos;
bLangBlockStmt.addStatement(returnStmt);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class SymbolEnter method createInitFunction.
private BLangFunction createInitFunction(DiagnosticPos pos, String name, Name sufix) {
BLangFunction initFunction = (BLangFunction) TreeBuilder.createFunctionNode();
initFunction.setName(createIdentifier(name + sufix.getValue()));
initFunction.flagSet = EnumSet.of(Flag.PUBLIC);
initFunction.pos = pos;
// Create body of the init function
BLangBlockStmt body = (BLangBlockStmt) TreeBuilder.createBlockNode();
body.pos = pos;
initFunction.setBody(body);
return initFunction;
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
@Override
public void visit(BLangForkJoin forkJoin) {
SymbolEnv forkJoinEnv = SymbolEnv.createFolkJoinEnv(forkJoin, this.env);
forkJoin.workers.forEach(e -> this.symbolEnter.defineNode(e, forkJoinEnv));
forkJoin.workers.forEach(e -> this.analyzeDef(e, forkJoinEnv));
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.env);
this.analyzeNode(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.analyzeNode(forkJoin.joinedBody, joinBodyEnv);
if (forkJoin.timeoutExpression != null) {
if (!this.isJoinResultType(forkJoin.timeoutVariable)) {
this.dlog.error(forkJoin.timeoutVariable.pos, DiagnosticCode.INVALID_WORKER_TIMEOUT_RESULT_TYPE);
}
/* create code black and environment for timeout section */
BLangBlockStmt timeoutVarBlock = this.generateCodeBlock(this.createVarDef(forkJoin.timeoutVariable));
SymbolEnv timeoutVarEnv = SymbolEnv.createBlockEnv(timeoutVarBlock, this.env);
this.typeChecker.checkExpr(forkJoin.timeoutExpression, timeoutVarEnv, Arrays.asList(symTable.intType));
this.analyzeNode(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.analyzeNode(forkJoin.timeoutBody, timeoutBodyEnv);
}
this.validateJoinWorkerList(forkJoin, forkJoinEnv);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangBlockStmt blockNode) {
SymbolEnv blockEnv = SymbolEnv.createBlockEnv(blockNode, this.env);
for (BLangStatement stmt : blockNode.stmts) {
if (stmt.getKind() != NodeKind.TRY && stmt.getKind() != NodeKind.CATCH && stmt.getKind() != NodeKind.IF) {
addLineNumberInfo(stmt.pos);
}
genNode(stmt, blockEnv);
// Update the maxRegIndexes structure
setMaxRegIndexes(regIndexes, maxRegIndexes);
// Reset the regIndexes structure for every statement
regIndexes = new VariableIndex(REG);
}
}
Aggregations