use of org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator 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);
}
}
use of org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addEnumerator.
public void addEnumerator(DiagnosticPos pos, Set<Whitespace> ws, String name) {
BLangEnumerator enumerator = (BLangEnumerator) TreeBuilder.createEnumeratorNode();
enumerator.pos = pos;
enumerator.addWS(ws);
enumerator.name = (BLangIdentifier) createIdentifier(name);
enumeratorList.add(enumerator);
}
use of org.wso2.ballerinalang.compiler.tree.BLangEnum.BLangEnumerator in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangEnum enumNode) {
BTypeSymbol enumSymbol = Symbols.createEnumSymbol(Flags.asMask(enumNode.flagSet), names.fromIdNode(enumNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
enumNode.symbol = enumSymbol;
defineSymbol(enumNode.pos, enumSymbol);
BEnumType enumType = new BEnumType(enumSymbol, null);
enumSymbol.type = enumType;
SymbolEnv enumEnv = SymbolEnv.createPkgLevelSymbolEnv(enumNode, enumSymbol.scope, this.env);
for (int i = 0; i < enumNode.enumerators.size(); i++) {
BLangEnumerator enumerator = enumNode.enumerators.get(i);
BVarSymbol enumeratorSymbol = new BVarSymbol(Flags.PUBLIC, names.fromIdNode(enumerator.name), enumSymbol.pkgID, enumType, enumSymbol);
enumeratorSymbol.docTag = DocTag.FIELD;
enumerator.symbol = enumeratorSymbol;
if (symResolver.checkForUniqueSymbol(enumerator.pos, enumEnv, enumeratorSymbol, enumeratorSymbol.tag)) {
enumEnv.scope.define(enumeratorSymbol.name, enumeratorSymbol);
}
}
}
Aggregations