Search in sources :

Example 1 with WorkerInfo

use of org.wso2.ballerinalang.programfile.WorkerInfo 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 2 with WorkerInfo

use of org.wso2.ballerinalang.programfile.WorkerInfo in project ballerina by ballerina-lang.

the class CodeGenerator method createResourceInfoEntry.

private void createResourceInfoEntry(BLangResource resourceNode, ServiceInfo serviceInfo) {
    BInvokableType resourceType = (BInvokableType) resourceNode.symbol.type;
    // Add resource name as an UTFCPEntry to the constant pool
    int serviceNameCPIndex = addUTF8CPEntry(currentPkgInfo, resourceNode.name.value);
    ResourceInfo resourceInfo = new ResourceInfo(currentPackageRefCPIndex, serviceNameCPIndex);
    resourceInfo.paramTypes = resourceType.paramTypes.toArray(new BType[0]);
    setParameterNames(resourceNode, resourceInfo);
    resourceInfo.retParamTypes = new BType[0];
    resourceInfo.signatureCPIndex = addUTF8CPEntry(currentPkgInfo, generateFunctionSig(resourceInfo.paramTypes, resourceInfo.retParamTypes));
    // Add worker info
    int workerNameCPIndex = addUTF8CPEntry(currentPkgInfo, "default");
    resourceInfo.defaultWorkerInfo = new WorkerInfo(workerNameCPIndex, "default");
    resourceNode.workers.forEach(worker -> addWorkerInfoEntry(worker, resourceInfo));
    // Add resource info to the service info
    serviceInfo.resourceInfoMap.put(resourceNode.name.getValue(), resourceInfo);
}
Also used : ResourceInfo(org.wso2.ballerinalang.programfile.ResourceInfo) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) WorkerInfo(org.wso2.ballerinalang.programfile.WorkerInfo) BInvokableType(org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 3 with WorkerInfo

use of org.wso2.ballerinalang.programfile.WorkerInfo in project ballerina by ballerina-lang.

the class CodeGenerator method processWorker.

private void processWorker(BLangInvokableNode invokableNode, WorkerInfo workerInfo, BLangBlockStmt body, LocalVariableAttributeInfo localVarAttributeInfo, SymbolEnv invokableSymbolEnv, boolean defaultWorker, VariableIndex lvIndexCopy) {
    int codeAttrNameCPIndex = this.addUTF8CPEntry(this.currentPkgInfo, AttributeInfo.Kind.CODE_ATTRIBUTE.value());
    workerInfo.codeAttributeInfo.attributeNameIndex = codeAttrNameCPIndex;
    workerInfo.addAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE, localVarAttributeInfo);
    if (body != null) {
        localVarAttrInfo = new LocalVariableAttributeInfo(localVarAttributeInfo.attributeNameIndex);
        localVarAttrInfo.localVars = new ArrayList<>(localVarAttributeInfo.localVars);
        workerInfo.addAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE, localVarAttrInfo);
        workerInfo.codeAttributeInfo.codeAddrs = nextIP();
        this.lvIndexes = lvIndexCopy;
        this.currentWorkerInfo = workerInfo;
        this.genNode(body, invokableSymbolEnv);
    }
    this.endWorkerInfoUnit(workerInfo.codeAttributeInfo);
    this.emit(InstructionCodes.HALT);
}
Also used : LocalVariableAttributeInfo(org.wso2.ballerinalang.programfile.attributes.LocalVariableAttributeInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 4 with WorkerInfo

use of org.wso2.ballerinalang.programfile.WorkerInfo in project ballerina by ballerina-lang.

the class CodeGenerator method addWorkerInfoEntries.

private void addWorkerInfoEntries(CallableUnitInfo callableUnitInfo, List<BLangWorker> workers) {
    UTF8CPEntry workerNameCPEntry = new UTF8CPEntry("default");
    int workerNameCPIndex = this.currentPkgInfo.addCPEntry(workerNameCPEntry);
    WorkerInfo defaultWorkerInfo = new WorkerInfo(workerNameCPIndex, "default");
    callableUnitInfo.defaultWorkerInfo = defaultWorkerInfo;
    for (BLangWorker worker : workers) {
        workerNameCPEntry = new UTF8CPEntry(worker.name.value);
        workerNameCPIndex = currentPkgInfo.addCPEntry(workerNameCPEntry);
        WorkerInfo workerInfo = new WorkerInfo(workerNameCPIndex, worker.getName().value);
        callableUnitInfo.addWorkerInfo(worker.getName().value, workerInfo);
    }
}
Also used : UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker) WorkerInfo(org.wso2.ballerinalang.programfile.WorkerInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 5 with WorkerInfo

use of org.wso2.ballerinalang.programfile.WorkerInfo in project ballerina by ballerina-lang.

the class CodeGenerator method populateForkJoinWorkerInfo.

private void populateForkJoinWorkerInfo(BLangForkJoin forkJoin, ForkjoinInfo forkjoinInfo) {
    for (BLangWorker worker : forkJoin.workers) {
        UTF8CPEntry workerNameCPEntry = new UTF8CPEntry(worker.name.value);
        int workerNameCPIndex = this.currentPkgInfo.addCPEntry(workerNameCPEntry);
        WorkerInfo workerInfo = new WorkerInfo(workerNameCPIndex, worker.name.value);
        forkjoinInfo.addWorkerInfo(worker.name.value, workerInfo);
    }
}
Also used : UTF8CPEntry(org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry) BLangWorker(org.wso2.ballerinalang.compiler.tree.BLangWorker) WorkerInfo(org.wso2.ballerinalang.programfile.WorkerInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Aggregations

BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)6 WorkerInfo (org.wso2.ballerinalang.programfile.WorkerInfo)5 BLangWorker (org.wso2.ballerinalang.compiler.tree.BLangWorker)3 UTF8CPEntry (org.wso2.ballerinalang.programfile.cpentries.UTF8CPEntry)3 BInvokableType (org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType)1 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)1 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)1 ResourceInfo (org.wso2.ballerinalang.programfile.ResourceInfo)1 LocalVariableAttributeInfo (org.wso2.ballerinalang.programfile.attributes.LocalVariableAttributeInfo)1