mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Reinstate PUSHS clearing the SECTION scope (#870)
* Reinstate PUSHS clearing the SECTION scope Otherwise you can use `PUSHS` to simulate the old `ds -21`, and possibly cause bugs * Have PUSHS push LOAD block state as well It does not make sense not to, and coud cause bugs.
This commit is contained in:
@@ -22,13 +22,16 @@ uint8_t fillByte;
|
||||
|
||||
struct SectionStackEntry {
|
||||
struct Section *section;
|
||||
struct Section *loadSection;
|
||||
char const *scope; /* Section's symbol scope */
|
||||
uint32_t offset;
|
||||
int32_t loadOffset;
|
||||
struct SectionStackEntry *next;
|
||||
};
|
||||
|
||||
struct SectionStackEntry *sectionStack;
|
||||
uint32_t curOffset; /* Offset into the current section (see sect_GetSymbolOffset) */
|
||||
struct Section *currentSection = NULL;
|
||||
static struct Section *currentLoadSection = NULL;
|
||||
int32_t loadOffset; /* Offset into the LOAD section's parent (see sect_GetOutputOffset) */
|
||||
|
||||
@@ -44,7 +47,7 @@ struct UnionStackEntry {
|
||||
static void checksection(void)
|
||||
{
|
||||
if (currentSection == NULL)
|
||||
fatalerror("Code generation before SECTION directive\n");
|
||||
fatalerror("Cannot output data outside of a SECTION\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -898,10 +901,17 @@ void out_PushSection(void)
|
||||
if (sect == NULL)
|
||||
fatalerror("No memory for section stack: %s\n", strerror(errno));
|
||||
sect->section = currentSection;
|
||||
sect->loadSection = currentLoadSection;
|
||||
sect->scope = sym_GetCurrentSymbolScope();
|
||||
sect->offset = curOffset;
|
||||
sect->loadOffset = loadOffset;
|
||||
sect->next = sectionStack;
|
||||
sectionStack = sect;
|
||||
|
||||
// Reset the section scope
|
||||
currentSection = NULL;
|
||||
currentLoadSection = NULL;
|
||||
sym_SetCurrentSymbolScope(NULL);
|
||||
}
|
||||
|
||||
void out_PopSection(void)
|
||||
@@ -917,8 +927,10 @@ void out_PopSection(void)
|
||||
sect = sectionStack;
|
||||
changeSection();
|
||||
currentSection = sect->section;
|
||||
currentLoadSection = sect->loadSection;
|
||||
sym_SetCurrentSymbolScope(sect->scope);
|
||||
curOffset = sect->offset;
|
||||
loadOffset = sect->loadOffset;
|
||||
|
||||
sectionStack = sect->next;
|
||||
free(sect);
|
||||
|
||||
Reference in New Issue
Block a user