use of org.wso2.ballerinalang.compiler.tree.BLangWorker in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangWorker workerNode) {
SymbolEnv workerEnv = SymbolEnv.createWorkerEnv(workerNode, this.env);
analyzeNode(workerNode.body, workerEnv);
}
use of org.wso2.ballerinalang.compiler.tree.BLangWorker in project ballerina by ballerina-lang.
the class CodeAnalyzer method visitInvocable.
private void visitInvocable(BLangInvokableNode invNode) {
this.resetFunction();
this.initNewWorkerActionSystem();
if (Symbols.isNative(invNode.symbol)) {
return;
}
boolean invokableReturns = invNode.retParams.size() > 0;
if (invNode.workers.isEmpty()) {
invNode.body.accept(this);
/* the function returns, but none of the statements surely returns */
if (invokableReturns && !this.statementReturns) {
this.dlog.error(invNode.pos, DiagnosticCode.INVOKABLE_MUST_RETURN, invNode.getKind().toString().toLowerCase());
}
} else {
boolean workerReturns = false;
for (BLangWorker worker : invNode.workers) {
worker.accept(this);
workerReturns = workerReturns || this.statementReturns;
this.resetStatementReturns();
}
if (invokableReturns && !workerReturns) {
this.dlog.error(invNode.pos, DiagnosticCode.ATLEAST_ONE_WORKER_MUST_RETURN, invNode.getKind().toString().toLowerCase());
}
}
this.finalizeCurrentWorkerActionSystem();
}
use of org.wso2.ballerinalang.compiler.tree.BLangWorker in project ballerina by ballerina-lang.
the class CodeGenerator method addWorkerInfoEntry.
private void addWorkerInfoEntry(BLangWorker worker, CallableUnitInfo callableUnitInfo) {
int workerNameCPIndex = addUTF8CPEntry(currentPkgInfo, worker.name.value);
WorkerInfo workerInfo = new WorkerInfo(workerNameCPIndex, worker.name.value);
callableUnitInfo.addWorkerInfo(worker.name.value, workerInfo);
}
use of org.wso2.ballerinalang.compiler.tree.BLangWorker in project ballerina by ballerina-lang.
the class BLangPackageBuilder method attachWorkerWS.
public void attachWorkerWS(Set<Whitespace> ws) {
BLangWorker worker = (BLangWorker) this.invokableNodeStack.peek();
worker.addWS(ws);
}
use of org.wso2.ballerinalang.compiler.tree.BLangWorker in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addWorker.
public void addWorker(DiagnosticPos pos, Set<Whitespace> ws, String workerName) {
BLangWorker worker = (BLangWorker) this.invokableNodeStack.pop();
worker.setName(createIdentifier(workerName));
worker.pos = pos;
worker.addWS(ws);
worker.setBody(this.blockNodeStack.pop());
if (this.forkJoinNodesStack.empty()) {
InvokableNode invokableNode = this.invokableNodeStack.peek();
invokableNode.getParameters().forEach(worker::addParameter);
invokableNode.getReturnParameters().forEach(worker::addReturnParameter);
invokableNode.addWorker(worker);
invokableNode.addFlag(Flag.PARALLEL);
} else {
((BLangForkJoin) this.forkJoinNodesStack.peek()).workers.add(worker);
}
}
Aggregations