aboutsummaryrefslogtreecommitdiff
path: root/source/20-codegen-compiler/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/20-codegen-compiler/main.cpp')
-rw-r--r--source/20-codegen-compiler/main.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/source/20-codegen-compiler/main.cpp b/source/20-codegen-compiler/main.cpp
index e9a449c..348d60e 100644
--- a/source/20-codegen-compiler/main.cpp
+++ b/source/20-codegen-compiler/main.cpp
@@ -474,7 +474,7 @@ void GenerateForEnum(CodegenOutput& headerOut, CodegenOutput& sourceOut, const D
{
auto& o = lookupTable.text;
// TODO use correct underlying type
- APPEND_FMT_LN(o, "constinit frozen::unordered_map<frozen::string, %s, %" PRId64 "> %s = {", decl.underlyingTypeStr.c_str(), filteredElements.size(), str2ValName);
+ APPEND_FMT_LN(o, "constinit frozen::unordered_map<frozen::string, %s, %" PRId64 "> %s = {", FSTR_LUT_LOOKUP(EnumUnderlyingType, decl.underlyingType), filteredElements.size(), str2ValName);
for (auto& elm : filteredElements) {
APPEND_FMT_LN(o, "{\"%s\", %" PRId64 "},", elm.name.c_str(), elm.value);
}
@@ -878,18 +878,12 @@ void ParseInputFileAndGenerate(AppState& as, CodegenLexer& /*lexingState*/ ls, s
++idx;
// Setting underlying type
- // NOTE: these two variables are only valid if we enter the EUT found branch
- size_t eutClauseBegin = idx + /* The ':' token */ 1;
- size_t eutClauseEnd;
if (auto eut = TryConsumeEnumUnderlyingTypeClause(ls);
eut != EUT_COUNT)
{
- eutClauseEnd = idx;
enumDecl.underlyingType = eut;
- enumDecl.underlyingTypeStr = CombineTokens(std::span(tokens.begin() + eutClauseBegin, eutClauseEnd - eutClauseBegin), " "sv);
} else {
enumDecl.underlyingType = EUT_Int32;
- enumDecl.underlyingTypeStr = "int";
}
int enumClosingBraceCount = 0;
@@ -1372,3 +1366,8 @@ where --output-dir=<path>: the *directory* to write generated contents to. Thi
return 0;
}
+
+// TODO move this function to CodegenDecl.cpp, after making LUT able to cross TUs
+std::string_view DeclEnum::GetUnderlyingTypeName() const {
+ return FSTR_LUT_LOOKUP(EnumUnderlyingType, underlyingType);
+}