mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-24 03:52:08 +00:00
PUSHS and POPS also affect the symbol scope
Now, when POPS is executed, it restores the symbol scope of the
corresponding PUSHS. That way, the local symbols previously available
can be used again after the POPS.
This is useful in cases like this one:
```
SECTION "Section 1", ROMX
BigFunction:
...
.loop:
...
PUSHS
SECTION "Section 2", ROMX
DataForBigFunction:
DB 1, 2, 3, 4, 5
POPS
ld a,BANK(DataForBigFunction)
ld hl,DataForBigFunction
...
jr .loop
```
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -42,6 +42,7 @@ struct PatchSymbol {
|
||||
|
||||
struct SectionStackEntry {
|
||||
struct Section *pSection;
|
||||
struct sSymbol *pScope; /* Section's symbol scope */
|
||||
struct SectionStackEntry *pNext;
|
||||
};
|
||||
|
||||
@@ -64,6 +65,7 @@ void out_PushSection(void)
|
||||
fatalerror("No memory for section stack");
|
||||
|
||||
pSect->pSection = pCurrentSection;
|
||||
pSect->pScope = sym_GetCurrentSymbolScope();
|
||||
pSect->pNext = pSectionStack;
|
||||
pSectionStack = pSect;
|
||||
}
|
||||
@@ -77,6 +79,7 @@ void out_PopSection(void)
|
||||
|
||||
pSect = pSectionStack;
|
||||
out_SetCurrentSection(pSect->pSection);
|
||||
sym_SetCurrentSymbolScope(pSect->pScope);
|
||||
pSectionStack = pSect->pNext;
|
||||
free(pSect);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user