diff --git a/include/asm/symbol.hpp b/include/asm/symbol.hpp index d9a098f2..fa556d6e 100644 --- a/include/asm/symbol.hpp +++ b/include/asm/symbol.hpp @@ -97,8 +97,8 @@ bool sym_IsPurgedExact(std::string const &symName); bool sym_IsPurgedScoped(std::string const &symName); void sym_Init(time_t now); -// Functions to save and restore the current symbol scope. -Symbol const *sym_GetCurrentSymbolScope(); -void sym_SetCurrentSymbolScope(Symbol const *newScope); +// Functions to save and restore the current label scope. +Symbol const *sym_GetCurrentLabelScope(); +void sym_SetCurrentLabelScope(Symbol const *newScope); #endif // RGBDS_ASM_SYMBOL_HPP diff --git a/src/asm/section.cpp b/src/asm/section.cpp index 38780f1a..b73505fe 100644 --- a/src/asm/section.cpp +++ b/src/asm/section.cpp @@ -395,7 +395,7 @@ static void changeSection() { if (!currentUnionStack.empty()) fatalerror("Cannot change the section within a UNION\n"); - sym_SetCurrentSymbolScope(nullptr); + sym_SetCurrentLabelScope(nullptr); } bool Section::isSizeKnown() const { @@ -473,7 +473,7 @@ void sect_SetLoadSection( Section *sect = getSection(name, type, org, attrs, mod); - currentLoadScope = sym_GetCurrentSymbolScope(); + currentLoadScope = sym_GetCurrentLabelScope(); changeSection(); loadOffset = curOffset - (mod == SECTION_UNION ? 0 : sect->size); curOffset -= loadOffset; @@ -490,7 +490,7 @@ void sect_EndLoadSection() { curOffset += loadOffset; loadOffset = 0; currentLoadSection = nullptr; - sym_SetCurrentSymbolScope(currentLoadScope); + sym_SetCurrentLabelScope(currentLoadScope); } Section *sect_GetSymbolSection() { @@ -935,7 +935,7 @@ void sect_PushSection() { sectionStack.push_front({ .section = currentSection, .loadSection = currentLoadSection, - .scope = sym_GetCurrentSymbolScope(), + .scope = sym_GetCurrentLabelScope(), .offset = curOffset, .loadOffset = loadOffset, .unionStack = {}, @@ -944,7 +944,7 @@ void sect_PushSection() { // Reset the section scope currentSection = nullptr; currentLoadSection = nullptr; - sym_SetCurrentSymbolScope(nullptr); + sym_SetCurrentLabelScope(nullptr); std::swap(currentUnionStack, sectionStack.front().unionStack); } @@ -961,7 +961,7 @@ void sect_PopSection() { changeSection(); currentSection = entry.section; currentLoadSection = entry.loadSection; - sym_SetCurrentSymbolScope(entry.scope); + sym_SetCurrentLabelScope(entry.scope); curOffset = entry.offset; loadOffset = entry.loadOffset; std::swap(currentUnionStack, entry.unionStack); @@ -979,5 +979,5 @@ void sect_EndSection() { // Reset the section scope currentSection = nullptr; - sym_SetCurrentSymbolScope(nullptr); + sym_SetCurrentLabelScope(nullptr); } diff --git a/src/asm/symbol.cpp b/src/asm/symbol.cpp index 6750a595..bf378b72 100644 --- a/src/asm/symbol.cpp +++ b/src/asm/symbol.cpp @@ -253,11 +253,11 @@ uint32_t sym_GetConstantValue(std::string const &symName) { return 0; } -Symbol const *sym_GetCurrentSymbolScope() { +Symbol const *sym_GetCurrentLabelScope() { return labelScope; } -void sym_SetCurrentSymbolScope(Symbol const *newScope) { +void sym_SetCurrentLabelScope(Symbol const *newScope) { labelScope = newScope; } @@ -415,6 +415,7 @@ Symbol *sym_AddLabel(std::string const &symName) { // Set the symbol as the new scope if (sym) labelScope = sym; + return sym; }