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);
}
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);
}
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);
}
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);
}
}
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);
}
}
Aggregations