Implement ENDSECTION (#1211)

This commit is contained in:
Rangi
2023-11-04 18:41:17 -04:00
committed by GitHub
parent 99727cbe99
commit 259ec58140
12 changed files with 44 additions and 9 deletions

View File

@@ -598,7 +598,7 @@ void sect_EndUnion(void)
void sect_CheckUnionClosed(void)
{
if (unionStack)
error("Unterminated UNION construct!\n");
error("Unterminated UNION construct\n");
}
// Output an absolute byte
@@ -965,7 +965,7 @@ void sect_PopSection(void)
fatalerror("No entries in the section stack\n");
if (currentLoadSection)
fatalerror("Cannot change the section within a `LOAD` block!\n");
fatalerror("Cannot change the section within a `LOAD` block\n");
struct SectionStackEntry *entry = sectionStack;
@@ -981,6 +981,22 @@ void sect_PopSection(void)
free(entry);
}
void sect_EndSection(void)
{
if (!currentSection)
fatalerror("Cannot end the section outside of a SECTION\n");
if (currentLoadSection)
fatalerror("Cannot end the section within a `LOAD` block\n");
if (unionStack)
fatalerror("Cannot end the section within a UNION\n");
// Reset the section scope
currentSection = NULL;
sym_SetCurrentSymbolScope(NULL);
}
bool sect_IsSizeKnown(struct Section const NONNULL(sect))
{
// SECTION UNION and SECTION FRAGMENT can still grow