mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Make ENDL optional like ENDSECTION (#1538)
Add warning for `LOAD` without `ENDL`
This commit is contained in:
@@ -425,14 +425,14 @@ void sect_NewSection(
|
||||
SectionSpec const &attrs,
|
||||
SectionModifier mod
|
||||
) {
|
||||
if (currentLoadSection)
|
||||
fatalerror("Cannot change the section within a `LOAD` block\n");
|
||||
|
||||
for (SectionStackEntry &entry : sectionStack) {
|
||||
if (entry.section && entry.section->name == name)
|
||||
fatalerror("Section '%s' is already on the stack\n", name.c_str());
|
||||
}
|
||||
|
||||
if (currentLoadSection)
|
||||
sect_EndLoadSection("SECTION");
|
||||
|
||||
Section *sect = getSection(name, type, org, attrs, mod);
|
||||
|
||||
changeSection();
|
||||
@@ -457,11 +457,6 @@ void sect_SetLoadSection(
|
||||
if (!requireCodeSection())
|
||||
return;
|
||||
|
||||
if (currentLoadSection) {
|
||||
error("`LOAD` blocks cannot be nested\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sect_HasData(type)) {
|
||||
error("`LOAD` blocks cannot create a ROM section\n");
|
||||
return;
|
||||
@@ -472,6 +467,9 @@ void sect_SetLoadSection(
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentLoadSection)
|
||||
sect_EndLoadSection("LOAD");
|
||||
|
||||
Section *sect = getSection(name, type, org, attrs, mod);
|
||||
|
||||
currentLoadLabelScopes = sym_GetCurrentLabelScopes();
|
||||
@@ -481,7 +479,14 @@ void sect_SetLoadSection(
|
||||
currentLoadSection = sect;
|
||||
}
|
||||
|
||||
void sect_EndLoadSection() {
|
||||
void sect_EndLoadSection(char const *cause) {
|
||||
if (cause)
|
||||
warning(
|
||||
WARNING_UNTERMINATED_LOAD,
|
||||
"`LOAD` block without `ENDL` terminated by `%s`\n",
|
||||
cause
|
||||
);
|
||||
|
||||
if (!currentLoadSection) {
|
||||
error("Found `ENDL` outside of a `LOAD` block\n");
|
||||
return;
|
||||
@@ -494,6 +499,11 @@ void sect_EndLoadSection() {
|
||||
sym_SetCurrentLabelScopes(currentLoadLabelScopes);
|
||||
}
|
||||
|
||||
void sect_CheckLoadClosed() {
|
||||
if (currentLoadSection)
|
||||
warning(WARNING_UNTERMINATED_LOAD, "`LOAD` block without `ENDL` terminated by EOF\n");
|
||||
}
|
||||
|
||||
Section *sect_GetSymbolSection() {
|
||||
return currentLoadSection ? currentLoadSection : currentSection;
|
||||
}
|
||||
@@ -954,7 +964,7 @@ void sect_PopSection() {
|
||||
fatalerror("No entries in the section stack\n");
|
||||
|
||||
if (currentLoadSection)
|
||||
fatalerror("Cannot change the section within a `LOAD` block\n");
|
||||
sect_EndLoadSection("POPS");
|
||||
|
||||
SectionStackEntry entry = sectionStack.front();
|
||||
sectionStack.pop_front();
|
||||
@@ -972,12 +982,12 @@ void sect_EndSection() {
|
||||
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 (!currentUnionStack.empty())
|
||||
fatalerror("Cannot end the section within a UNION\n");
|
||||
|
||||
if (currentLoadSection)
|
||||
sect_EndLoadSection("ENDSECTION");
|
||||
|
||||
// Reset the section scope
|
||||
currentSection = nullptr;
|
||||
sym_ResetCurrentLabelScopes();
|
||||
|
||||
Reference in New Issue
Block a user