Search in sources :

Example 1 with EnumeratorInfo

use of org.wso2.ballerinalang.programfile.EnumeratorInfo in project ballerina by ballerina-lang.

the class CodeGenerator method createEnumInfoEntry.

private void createEnumInfoEntry(BLangEnum enumNode) {
    BTypeSymbol enumSymbol = (BTypeSymbol) enumNode.symbol;
    // Add Enum name as an UTFCPEntry to the constant pool
    int enumNameCPIndex = addUTF8CPEntry(currentPkgInfo, enumSymbol.name.value);
    EnumInfo enumInfo = new EnumInfo(currentPackageRefCPIndex, enumNameCPIndex, enumSymbol.flags);
    currentPkgInfo.addEnumInfo(enumSymbol.name.value, enumInfo);
    enumInfo.enumType = (BEnumType) enumSymbol.type;
    for (int i = 0; i < enumNode.enumerators.size(); i++) {
        BLangEnumerator enumeratorNode = enumNode.enumerators.get(i);
        enumeratorNode.symbol.varIndex = new RegIndex(i, enumSymbol.type.tag);
        enumeratorNode.symbol.varIndex.isVarIndex = true;
        int enumeratorNameCPIndex = addUTF8CPEntry(currentPkgInfo, enumeratorNode.symbol.name.toString());
        EnumeratorInfo enumeratorInfo = new EnumeratorInfo(enumeratorNameCPIndex, i, enumInfo.enumType);
        enumInfo.enumeratorInfoList.add(enumeratorInfo);
    }
}
Also used : EnumInfo(org.wso2.ballerinalang.programfile.EnumInfo) BTypeSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol) BLangEnumerator(org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator) EnumeratorInfo(org.wso2.ballerinalang.programfile.EnumeratorInfo) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex)

Aggregations

BTypeSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol)1 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)1 BLangEnumerator (org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator)1 EnumInfo (org.wso2.ballerinalang.programfile.EnumInfo)1 EnumeratorInfo (org.wso2.ballerinalang.programfile.EnumeratorInfo)1 RegIndex (org.wso2.ballerinalang.programfile.Instruction.RegIndex)1