Store a pointer to the scoped label, not just its name

This commit is contained in:
Rangi42
2024-09-08 22:35:42 -04:00
committed by Eldred Habert
parent 1dcc000572
commit 155e7287db
3 changed files with 21 additions and 24 deletions

View File

@@ -31,7 +31,7 @@ struct UnionStackEntry {
struct SectionStackEntry {
Section *section;
Section *loadSection;
std::optional<std::string> scope; // Section's symbol scope
Symbol const *scope;
uint32_t offset;
int32_t loadOffset;
std::stack<UnionStackEntry> unionStack;
@@ -44,7 +44,7 @@ std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList
uint32_t curOffset; // Offset into the current section (see sect_GetSymbolOffset)
Section *currentSection = nullptr;
static Section *currentLoadSection = nullptr;
std::optional<std::string> currentLoadScope = std::nullopt;
static Symbol const *currentLoadScope = nullptr;
int32_t loadOffset; // Offset into the LOAD section's parent (see sect_GetOutputOffset)
// A quick check to see if we have an initialized section
@@ -395,7 +395,7 @@ static void changeSection() {
if (!currentUnionStack.empty())
fatalerror("Cannot change the section within a UNION\n");
sym_SetCurrentSymbolScope(std::nullopt);
sym_SetCurrentSymbolScope(nullptr);
}
bool Section::isSizeKnown() const {
@@ -944,7 +944,7 @@ void sect_PushSection() {
// Reset the section scope
currentSection = nullptr;
currentLoadSection = nullptr;
sym_SetCurrentSymbolScope(std::nullopt);
sym_SetCurrentSymbolScope(nullptr);
std::swap(currentUnionStack, sectionStack.front().unionStack);
}
@@ -979,5 +979,5 @@ void sect_EndSection() {
// Reset the section scope
currentSection = nullptr;
sym_SetCurrentSymbolScope(std::nullopt);
sym_SetCurrentSymbolScope(nullptr);
}