use of org.wso2.ballerinalang.programfile.ServiceInfo in project ballerina by ballerina-lang.
the class CodeGenerator method createServiceInfoEntry.
private void createServiceInfoEntry(BLangService serviceNode) {
// Add service name as an UTFCPEntry to the constant pool
int serviceNameCPIndex = addUTF8CPEntry(currentPkgInfo, serviceNode.name.value);
// Create service info
if (serviceNode.endpointType != null) {
String endPointQName = serviceNode.endpointType.tsymbol.toString();
// TODO: bvmAlias needed?
int epNameCPIndex = addUTF8CPEntry(currentPkgInfo, endPointQName);
ServiceInfo serviceInfo = new ServiceInfo(currentPackageRefCPIndex, serviceNameCPIndex, serviceNode.symbol.flags, epNameCPIndex);
// Add service level variables
int localVarAttNameIndex = addUTF8CPEntry(currentPkgInfo, AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE.value());
LocalVariableAttributeInfo localVarAttributeInfo = new LocalVariableAttributeInfo(localVarAttNameIndex);
serviceNode.vars.forEach(var -> visitVarSymbol(var.var.symbol, pvIndexes, localVarAttributeInfo));
serviceInfo.addAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE, localVarAttributeInfo);
// Create the init function info
BLangFunction serviceInitFunction = (BLangFunction) serviceNode.getInitFunction();
createFunctionInfoEntry(serviceInitFunction);
serviceInfo.initFuncInfo = currentPkgInfo.functionInfoMap.get(serviceInitFunction.name.toString());
currentPkgInfo.addServiceInfo(serviceNode.name.value, serviceInfo);
// Create resource info entries for all resources
serviceNode.resources.forEach(res -> createResourceInfoEntry(res, serviceInfo));
}
}
use of org.wso2.ballerinalang.programfile.ServiceInfo 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);
}
Aggregations