use of org.ballerinalang.util.codegen.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class ProgramFileReader method readTransformerInfo.
private void readTransformerInfo(DataInputStream dataInStream, PackageInfo packageInfo) throws IOException {
int transformerNameCPIndex = dataInStream.readInt();
UTF8CPEntry transformerNameUTF8Entry = (UTF8CPEntry) packageInfo.getCPEntry(transformerNameCPIndex);
TransformerInfo transformerInfo = new TransformerInfo(packageInfo.getPkgNameCPIndex(), packageInfo.getPkgPath(), transformerNameCPIndex, transformerNameUTF8Entry.getValue());
transformerInfo.setPackageInfo(packageInfo);
packageInfo.addTransformerInfo(transformerNameUTF8Entry.getValue(), transformerInfo);
int transformerSigCPIndex = dataInStream.readInt();
UTF8CPEntry transformerSigUTF8Entry = (UTF8CPEntry) packageInfo.getCPEntry(transformerSigCPIndex);
setCallableUnitSignature(transformerInfo, transformerSigUTF8Entry.getValue(), packageInfo);
boolean nativeFunc = Flags.isFlagOn(dataInStream.readInt(), Flags.NATIVE);
transformerInfo.setNative(nativeFunc);
int workerDataChannelsLength = dataInStream.readShort();
for (int i = 0; i < workerDataChannelsLength; i++) {
readWorkerDataChannelEntries(dataInStream, packageInfo, transformerInfo);
}
// Read worker info entries
readWorkerInfoEntries(dataInStream, packageInfo, transformerInfo);
// Read attributes
readAttributeInfoEntries(dataInStream, packageInfo, transformerInfo);
}
use of org.ballerinalang.util.codegen.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class ProgramFileReader method getForkJoinInfo.
private ForkjoinInfo getForkJoinInfo(DataInputStream dataInStream, PackageInfo packageInfo) throws IOException {
int indexCPIndex = dataInStream.readInt();
int argRegLength = dataInStream.readShort();
int[] argRegs = new int[argRegLength];
for (int i = 0; i < argRegLength; i++) {
argRegs[i] = dataInStream.readInt();
}
ForkJoinCPEntry forkJoinCPEntry = (ForkJoinCPEntry) packageInfo.getCPEntry(indexCPIndex);
ForkjoinInfo forkjoinInfo = new ForkjoinInfo(argRegs);
forkjoinInfo.setIndex(forkJoinCPEntry.getForkJoinCPIndex());
forkjoinInfo.setIndexCPIndex(indexCPIndex);
int workerCount = dataInStream.readShort();
for (int i = 0; i < workerCount; i++) {
WorkerInfo workerInfo = getWorkerInfo(dataInStream, packageInfo);
forkjoinInfo.addWorkerInfo(workerInfo.getWorkerName(), workerInfo);
}
boolean isTimeoutAvailable = dataInStream.readBoolean();
forkjoinInfo.setTimeoutAvailable(isTimeoutAvailable);
int joinTypeCPIndex = dataInStream.readInt();
UTF8CPEntry joinTypeCPEntry = (UTF8CPEntry) packageInfo.getCPEntry(joinTypeCPIndex);
forkjoinInfo.setJoinType(joinTypeCPEntry.getValue());
forkjoinInfo.setJoinTypeCPIndex(joinTypeCPIndex);
int joinWorkerCount = dataInStream.readInt();
forkjoinInfo.setWorkerCount(joinWorkerCount);
int joinWrkrCPIndexesLen = dataInStream.readShort();
int[] joinWrkrCPIndexes = new int[joinWrkrCPIndexesLen];
String[] joinWrkrNames = new String[joinWrkrCPIndexesLen];
for (int i = 0; i < joinWrkrCPIndexesLen; i++) {
int cpIndex = dataInStream.readInt();
UTF8CPEntry workerNameCPEntry = (UTF8CPEntry) packageInfo.getCPEntry(cpIndex);
joinWrkrCPIndexes[i] = cpIndex;
joinWrkrNames[i] = workerNameCPEntry.getValue();
}
forkjoinInfo.setJoinWrkrNameIndexes(joinWrkrCPIndexes);
forkjoinInfo.setJoinWorkerNames(joinWrkrNames);
forkJoinCPEntry.setForkjoinInfo(forkjoinInfo);
return forkjoinInfo;
}
use of org.ballerinalang.util.codegen.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class ProgramFileReader method getGlobalVarInfo.
private PackageVarInfo getGlobalVarInfo(DataInputStream dataInStream, ConstantPool constantPool) throws IOException {
// Read variable name;
int nameCPIndex = dataInStream.readInt();
UTF8CPEntry nameUTF8CPEntry = (UTF8CPEntry) constantPool.getCPEntry(nameCPIndex);
// Read variable type;
int sigCPIndex = dataInStream.readInt();
UTF8CPEntry sigUTF8CPEntry = (UTF8CPEntry) constantPool.getCPEntry(sigCPIndex);
int globalMemIndex = dataInStream.readInt();
PackageVarInfo packageVarInfo = new PackageVarInfo(nameCPIndex, nameUTF8CPEntry.getValue(), sigCPIndex, sigUTF8CPEntry.getValue(), globalMemIndex);
// Read attributes
readAttributeInfoEntries(dataInStream, constantPool, packageVarInfo);
return packageVarInfo;
}
use of org.ballerinalang.util.codegen.cpentries.UTF8CPEntry in project ballerina by ballerina-lang.
the class ProgramFileReader method readConnectorActionInfoEntries.
private void readConnectorActionInfoEntries(DataInputStream dataInStream, PackageInfo packageInfo) throws IOException {
for (ConnectorInfo connectorInfo : packageInfo.getConnectorInfoEntries()) {
// Read action info entries
int actionCount = dataInStream.readShort();
for (int j = 0; j < actionCount; j++) {
// Read action name;
int actionNameCPIndex = dataInStream.readInt();
UTF8CPEntry actionNameUTF8Entry = (UTF8CPEntry) packageInfo.getCPEntry(actionNameCPIndex);
String actionName = actionNameUTF8Entry.getValue();
ActionInfo actionInfo = new ActionInfo(packageInfo.getPkgNameCPIndex(), packageInfo.getPkgPath(), actionNameCPIndex, actionName, connectorInfo);
actionInfo.setPackageInfo(packageInfo);
connectorInfo.addActionInfo(actionName, actionInfo);
// Read action signature
int actionSigCPIndex = dataInStream.readInt();
UTF8CPEntry actionSigUTF8Entry = (UTF8CPEntry) packageInfo.getCPEntry(actionSigCPIndex);
actionInfo.setSignatureCPIndex(actionSigCPIndex);
actionInfo.setSignature(actionSigUTF8Entry.getValue());
int flags = dataInStream.readInt();
// actionInfo.setflags(flags);
setCallableUnitSignature(actionInfo, actionSigUTF8Entry.getValue(), packageInfo);
// TODO Temp solution.
boolean nativeAction = dataInStream.readByte() == 1;
actionInfo.setNative(nativeAction);
int workerDataChannelsLength = dataInStream.readShort();
for (int k = 0; k < workerDataChannelsLength; k++) {
readWorkerDataChannelEntries(dataInStream, packageInfo, actionInfo);
}
// Read worker info entries
readWorkerInfoEntries(dataInStream, packageInfo, actionInfo);
if (nativeAction) {
NativeCallableUnit nativeActionObj = NativeUnitLoader.getInstance().loadNativeAction(actionInfo.getPkgPath(), actionInfo.getConnectorInfo().getName(), actionInfo.getName());
if (nativeActionObj == null && !actionInfo.name.equals("<init>")) {
throw new BLangRuntimeException("native action not available " + actionInfo.getPkgPath() + ":" + actionInfo.getConnectorInfo().getName() + "." + actionName);
}
actionInfo.setNativeCallableUnit(nativeActionObj);
}
// Read attributes of the struct info
readAttributeInfoEntries(dataInStream, packageInfo, actionInfo);
}
// Read attributes of the struct info
readAttributeInfoEntries(dataInStream, packageInfo, connectorInfo);
}
}
Aggregations