use of org.wso2.ballerinalang.programfile.CallableUnitInfo 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.CallableUnitInfo in project ballerina by ballerina-lang.
the class CodeGenerator method getWorkerDataChannelInfo.
private WorkerDataChannelInfo getWorkerDataChannelInfo(CallableUnitInfo callableUnit, String source, String target) {
WorkerDataChannelInfo workerDataChannelInfo = callableUnit.getWorkerDataChannelInfo(WorkerDataChannelInfo.generateChannelName(source, target));
if (workerDataChannelInfo == null) {
UTF8CPEntry sourceCPEntry = new UTF8CPEntry(source);
int sourceCPIndex = this.currentPkgInfo.addCPEntry(sourceCPEntry);
UTF8CPEntry targetCPEntry = new UTF8CPEntry(target);
int targetCPIndex = this.currentPkgInfo.addCPEntry(targetCPEntry);
workerDataChannelInfo = new WorkerDataChannelInfo(sourceCPIndex, source, targetCPIndex, target);
workerDataChannelInfo.setUniqueName(workerDataChannelInfo.getChannelName() + this.workerChannelCount);
String uniqueName = workerDataChannelInfo.getUniqueName();
UTF8CPEntry uniqueNameCPEntry = new UTF8CPEntry(uniqueName);
int uniqueNameCPIndex = this.currentPkgInfo.addCPEntry(uniqueNameCPEntry);
workerDataChannelInfo.setUniqueNameCPIndex(uniqueNameCPIndex);
callableUnit.addWorkerDataChannelInfo(workerDataChannelInfo);
this.workerChannelCount++;
}
return workerDataChannelInfo;
}
use of org.wso2.ballerinalang.programfile.CallableUnitInfo in project ballerina by ballerina-lang.
the class CodeGenerator method addParameterDefaultValues.
private void addParameterDefaultValues(BLangInvokableNode invokableNode, CallableUnitInfo callableUnitInfo) {
int paramDefaultsAttrNameIndex = addUTF8CPEntry(currentPkgInfo, AttributeInfo.Kind.PARAMETER_DEFAULTS_ATTRIBUTE.value());
ParamDefaultValueAttributeInfo paramDefaulValAttrInfo = new ParamDefaultValueAttributeInfo(paramDefaultsAttrNameIndex);
// Only named parameters can have default values.
for (BLangVariableDef param : invokableNode.defaultableParams) {
DefaultValue defaultVal = getDefaultValue((BLangLiteral) param.var.expr);
paramDefaulValAttrInfo.addParamDefaultValueInfo(defaultVal);
}
callableUnitInfo.addAttributeInfo(AttributeInfo.Kind.PARAMETER_DEFAULTS_ATTRIBUTE, paramDefaulValAttrInfo);
}
use of org.wso2.ballerinalang.programfile.CallableUnitInfo 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));
}
}
}
use of org.wso2.ballerinalang.programfile.CallableUnitInfo 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);
}
}
Aggregations