Search in sources :

Example 6 with BLangWorker

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

the class TreeVisitor method visit.

@Override
public void visit(BLangWorker workerNode) {
    SymbolEnv workerEnv = SymbolEnv.createWorkerEnv(workerNode, this.symbolEnv);
    this.blockOwnerStack.push(workerNode);
    this.acceptNode(workerNode.body, workerEnv);
    this.blockOwnerStack.pop();
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 7 with BLangWorker

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

the class SymbolEnter method visit.

@Override
public void visit(BLangWorker workerNode) {
    BInvokableSymbol workerSymbol = Symbols.createWorkerSymbol(Flags.asMask(workerNode.flagSet), names.fromIdNode(workerNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
    workerNode.symbol = workerSymbol;
    defineSymbolWithCurrentEnvOwner(workerNode.pos, workerSymbol);
}
Also used : BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)

Example 8 with BLangWorker

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

the class TaintAnalyzer method analyzeReturnTaintedStatus.

private void analyzeReturnTaintedStatus(BLangInvokableNode invokableNode, SymbolEnv symbolEnv) {
    invokableNode.endpoints.forEach(endpoint -> endpoint.accept(this));
    if (invokableNode.workers.isEmpty()) {
        analyzeNode(invokableNode.body, symbolEnv);
    } else {
        for (BLangWorker worker : invokableNode.workers) {
            worker.endpoints.forEach(endpoint -> endpoint.accept(this));
            analyzeNode(worker, symbolEnv);
            if (this.blockedNode != null || taintErrorSet.size() > 0) {
                break;
            }
        }
    }
}
Also used : BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker)

Example 9 with BLangWorker

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

the class SemanticAnalyzer method visit.

@Override
public void visit(BLangWorker workerNode) {
    SymbolEnv workerEnv = SymbolEnv.createWorkerEnv(workerNode, this.env);
    this.analyzeNode(workerNode.body, workerEnv);
}
Also used : SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 10 with BLangWorker

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

the class CodeGenerator method visitInvokableNode.

private void visitInvokableNode(BLangInvokableNode invokableNode, CallableUnitInfo callableUnitInfo, SymbolEnv invokableSymbolEnv) {
    int localVarAttrNameIndex = addUTF8CPEntry(currentPkgInfo, AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE.value());
    LocalVariableAttributeInfo localVarAttributeInfo = new LocalVariableAttributeInfo(localVarAttrNameIndex);
    // TODO Read annotations attached to this callableUnit
    // Add local variable indexes to the parameters and return parameters
    visitInvokableNodeParams(invokableNode.symbol, callableUnitInfo, localVarAttributeInfo);
    if (Symbols.isNative(invokableNode.symbol)) {
        this.processWorker(invokableNode, callableUnitInfo.defaultWorkerInfo, null, localVarAttributeInfo, invokableSymbolEnv, true, null);
    } else {
        // Clone lvIndex structure here. This structure contain local variable indexes of the input and
        // out parameters and they are common for all the workers.
        VariableIndex lvIndexCopy = this.copyVarIndex(lvIndexes);
        this.processWorker(invokableNode, callableUnitInfo.defaultWorkerInfo, invokableNode.body, localVarAttributeInfo, invokableSymbolEnv, true, lvIndexCopy);
        for (BLangWorker worker : invokableNode.getWorkers()) {
            this.processWorker(invokableNode, callableUnitInfo.getWorkerInfo(worker.name.value), worker.body, localVarAttributeInfo, invokableSymbolEnv, false, this.copyVarIndex(lvIndexCopy));
        }
    }
}
Also used : BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker) LocalVariableAttributeInfo(org.wso2.ballerinalang.programfile.attributes.LocalVariableAttributeInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

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