Search in sources :

Example 1 with WorkerDataIndex

use of org.ballerinalang.util.program.WorkerDataIndex in project ballerina by ballerina-lang.

the class CallableUnitInfo method calculateWorkerDataIndex.

private WorkerDataIndex calculateWorkerDataIndex(BType[] retTypes) {
    WorkerDataIndex index = new WorkerDataIndex();
    index.retRegs = new int[retTypes.length];
    for (int i = 0; i < retTypes.length; i++) {
        BType retType = retTypes[i];
        switch(retType.getTag()) {
            case TypeTags.INT_TAG:
                index.retRegs[i] = index.longRegCount++;
                break;
            case TypeTags.FLOAT_TAG:
                index.retRegs[i] = index.doubleRegCount++;
                break;
            case TypeTags.STRING_TAG:
                index.retRegs[i] = index.stringRegCount++;
                break;
            case TypeTags.BOOLEAN_TAG:
                index.retRegs[i] = index.intRegCount++;
                break;
            case TypeTags.BLOB_TAG:
                index.retRegs[i] = index.byteRegCount++;
                break;
            default:
                index.retRegs[i] = index.refRegCount++;
                break;
        }
    }
    return index;
}
Also used : BType(org.ballerinalang.model.types.BType) WorkerDataIndex(org.ballerinalang.util.program.WorkerDataIndex)

Aggregations

BType (org.ballerinalang.model.types.BType)1 WorkerDataIndex (org.ballerinalang.util.program.WorkerDataIndex)1