Enums: Make EnumDefinition use EnumValues instead of Strings as children.
This allows us to store the index of the enum value along the name. The index can be used to compare two enum values in assembler. Later on this might be used to enable users of KLang to set arbitrary values as the index of an enum value.
This commit is contained in:
@@ -355,7 +355,7 @@ public class ContextAnalysis extends KlangBaseVisitor<Node> {
|
||||
}
|
||||
|
||||
var enumValueName = path.get(0);
|
||||
if (Arrays.stream(enumDef.enums).noneMatch(e -> e.equals(enumValueName))) {
|
||||
if (Arrays.stream(enumDef.enums).noneMatch(e -> e.value.equals(enumValueName))) {
|
||||
var error = "Unknown enum value " + enumValueName + " of enum " + enumDef.name + ".";
|
||||
throw new RuntimeException(Helper.getErrorPrefix(line, col) + error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user