Search in sources :

Example 16 with UTF8CPEntry

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);
}
Also used : UTF8CPEntry(org.ballerinalang.util.codegen.cpentries.UTF8CPEntry)

Example 17 with UTF8CPEntry

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;
}
Also used : UTF8CPEntry(org.ballerinalang.util.codegen.cpentries.UTF8CPEntry) ForkJoinCPEntry(org.ballerinalang.util.codegen.cpentries.ForkJoinCPEntry)

Example 18 with UTF8CPEntry

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;
}
Also used : UTF8CPEntry(org.ballerinalang.util.codegen.cpentries.UTF8CPEntry)

Example 19 with UTF8CPEntry

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);
    }
}
Also used : UTF8CPEntry(org.ballerinalang.util.codegen.cpentries.UTF8CPEntry) BLangRuntimeException(org.ballerinalang.util.exceptions.BLangRuntimeException) NativeCallableUnit(org.ballerinalang.model.NativeCallableUnit)

Aggregations

UTF8CPEntry (org.ballerinalang.util.codegen.cpentries.UTF8CPEntry)19 WorkerDataChannelRefCPEntry (org.ballerinalang.util.codegen.cpentries.WorkerDataChannelRefCPEntry)4 ProgramFileFormatException (org.ballerinalang.util.exceptions.ProgramFileFormatException)4 ForkJoinCPEntry (org.ballerinalang.util.codegen.cpentries.ForkJoinCPEntry)3 TypeRefCPEntry (org.ballerinalang.util.codegen.cpentries.TypeRefCPEntry)3 NativeCallableUnit (org.ballerinalang.model.NativeCallableUnit)2 BStructType (org.ballerinalang.model.types.BStructType)2 BType (org.ballerinalang.model.types.BType)2 CodeAttributeInfo (org.ballerinalang.util.codegen.attributes.CodeAttributeInfo)2 ActionRefCPEntry (org.ballerinalang.util.codegen.cpentries.ActionRefCPEntry)2 FloatCPEntry (org.ballerinalang.util.codegen.cpentries.FloatCPEntry)2 FunctionRefCPEntry (org.ballerinalang.util.codegen.cpentries.FunctionRefCPEntry)2 IntegerCPEntry (org.ballerinalang.util.codegen.cpentries.IntegerCPEntry)2 StructureRefCPEntry (org.ballerinalang.util.codegen.cpentries.StructureRefCPEntry)2 TransformerRefCPEntry (org.ballerinalang.util.codegen.cpentries.TransformerRefCPEntry)2 BLangRuntimeException (org.ballerinalang.util.exceptions.BLangRuntimeException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 BConnectorType (org.ballerinalang.model.types.BConnectorType)1 BEnumType (org.ballerinalang.model.types.BEnumType)1