Search in sources :

Example 1 with BLangWorker

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);
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 2 with BLangWorker

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();
}
Also used : BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker)

Example 3 with BLangWorker

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);
}
Also used : WorkerInfo(org.wso2.ballerinalang.programfile.WorkerInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 4 with BLangWorker

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);
}
Also used : BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker)

Example 5 with BLangWorker

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);
    }
}
Also used : BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker) InvokableNode(org.ballerinalang.model.tree.InvokableNode)

Aggregations

BLangWorker (org.wso2.ballerinalang.compiler.tree.BLangWorker)9 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)5 WorkerInfo (org.wso2.ballerinalang.programfile.WorkerInfo)4 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)3 UTF8CPEntry (org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry)3 Token (org.antlr.v4.runtime.Token)1 TokenStream (org.antlr.v4.runtime.TokenStream)1 InvokableNode (org.ballerinalang.model.tree.InvokableNode)1 CompletionItem (org.eclipse.lsp4j.CompletionItem)1 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)1 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)1 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)1 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)1 LocalVariableAttributeInfo (org.wso2.ballerinalang.programfile.attributes.LocalVariableAttributeInfo)1