Refer to "label scope", not "symbol scope"

This commit is contained in:
Rangi42
2024-09-09 12:21:23 -04:00
committed by Eldred Habert
parent 750e69c5a6
commit 1adf68d018
3 changed files with 13 additions and 12 deletions

View File

@@ -97,8 +97,8 @@ bool sym_IsPurgedExact(std::string const &symName);
bool sym_IsPurgedScoped(std::string const &symName); bool sym_IsPurgedScoped(std::string const &symName);
void sym_Init(time_t now); void sym_Init(time_t now);
// Functions to save and restore the current symbol scope. // Functions to save and restore the current label scope.
Symbol const *sym_GetCurrentSymbolScope(); Symbol const *sym_GetCurrentLabelScope();
void sym_SetCurrentSymbolScope(Symbol const *newScope); void sym_SetCurrentLabelScope(Symbol const *newScope);
#endif // RGBDS_ASM_SYMBOL_HPP #endif // RGBDS_ASM_SYMBOL_HPP

View File

@@ -395,7 +395,7 @@ static void changeSection() {
if (!currentUnionStack.empty()) if (!currentUnionStack.empty())
fatalerror("Cannot change the section within a UNION\n"); fatalerror("Cannot change the section within a UNION\n");
sym_SetCurrentSymbolScope(nullptr); sym_SetCurrentLabelScope(nullptr);
} }
bool Section::isSizeKnown() const { bool Section::isSizeKnown() const {
@@ -473,7 +473,7 @@ void sect_SetLoadSection(
Section *sect = getSection(name, type, org, attrs, mod); Section *sect = getSection(name, type, org, attrs, mod);
currentLoadScope = sym_GetCurrentSymbolScope(); currentLoadScope = sym_GetCurrentLabelScope();
changeSection(); changeSection();
loadOffset = curOffset - (mod == SECTION_UNION ? 0 : sect->size); loadOffset = curOffset - (mod == SECTION_UNION ? 0 : sect->size);
curOffset -= loadOffset; curOffset -= loadOffset;
@@ -490,7 +490,7 @@ void sect_EndLoadSection() {
curOffset += loadOffset; curOffset += loadOffset;
loadOffset = 0; loadOffset = 0;
currentLoadSection = nullptr; currentLoadSection = nullptr;
sym_SetCurrentSymbolScope(currentLoadScope); sym_SetCurrentLabelScope(currentLoadScope);
} }
Section *sect_GetSymbolSection() { Section *sect_GetSymbolSection() {
@@ -935,7 +935,7 @@ void sect_PushSection() {
sectionStack.push_front({ sectionStack.push_front({
.section = currentSection, .section = currentSection,
.loadSection = currentLoadSection, .loadSection = currentLoadSection,
.scope = sym_GetCurrentSymbolScope(), .scope = sym_GetCurrentLabelScope(),
.offset = curOffset, .offset = curOffset,
.loadOffset = loadOffset, .loadOffset = loadOffset,
.unionStack = {}, .unionStack = {},
@@ -944,7 +944,7 @@ void sect_PushSection() {
// Reset the section scope // Reset the section scope
currentSection = nullptr; currentSection = nullptr;
currentLoadSection = nullptr; currentLoadSection = nullptr;
sym_SetCurrentSymbolScope(nullptr); sym_SetCurrentLabelScope(nullptr);
std::swap(currentUnionStack, sectionStack.front().unionStack); std::swap(currentUnionStack, sectionStack.front().unionStack);
} }
@@ -961,7 +961,7 @@ void sect_PopSection() {
changeSection(); changeSection();
currentSection = entry.section; currentSection = entry.section;
currentLoadSection = entry.loadSection; currentLoadSection = entry.loadSection;
sym_SetCurrentSymbolScope(entry.scope); sym_SetCurrentLabelScope(entry.scope);
curOffset = entry.offset; curOffset = entry.offset;
loadOffset = entry.loadOffset; loadOffset = entry.loadOffset;
std::swap(currentUnionStack, entry.unionStack); std::swap(currentUnionStack, entry.unionStack);
@@ -979,5 +979,5 @@ void sect_EndSection() {
// Reset the section scope // Reset the section scope
currentSection = nullptr; currentSection = nullptr;
sym_SetCurrentSymbolScope(nullptr); sym_SetCurrentLabelScope(nullptr);
} }

View File

@@ -253,11 +253,11 @@ uint32_t sym_GetConstantValue(std::string const &symName) {
return 0; return 0;
} }
Symbol const *sym_GetCurrentSymbolScope() { Symbol const *sym_GetCurrentLabelScope() {
return labelScope; return labelScope;
} }
void sym_SetCurrentSymbolScope(Symbol const *newScope) { void sym_SetCurrentLabelScope(Symbol const *newScope) {
labelScope = newScope; labelScope = newScope;
} }
@@ -415,6 +415,7 @@ Symbol *sym_AddLabel(std::string const &symName) {
// Set the symbol as the new scope // Set the symbol as the new scope
if (sym) if (sym)
labelScope = sym; labelScope = sym;
return sym; return sym;
} }