mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Merge pull request #602 from NieDzejkob/shiftstorm
Report only one error when invalid shift has argument
This commit is contained in:
@@ -128,12 +128,17 @@ uint32_t macro_UseNewUniqueID(void)
|
||||
return maxUniqueID;
|
||||
}
|
||||
|
||||
void macro_ShiftCurrentArgs(void)
|
||||
void macro_ShiftCurrentArgs(int32_t count)
|
||||
{
|
||||
if (!macroArgs)
|
||||
if (!macroArgs) {
|
||||
error("Cannot shift macro arguments outside of a macro\n");
|
||||
else if (macroArgs->shift != macroArgs->nbArgs)
|
||||
macroArgs->shift++;
|
||||
} else if (count < 0) {
|
||||
error("Cannot shift arguments by negative amount %" PRId32 "\n", count);
|
||||
} else if (macroArgs->shift < macroArgs->nbArgs) {
|
||||
macroArgs->shift += count;
|
||||
if (macroArgs->shift > macroArgs->nbArgs)
|
||||
macroArgs->shift = macroArgs->nbArgs;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t macro_NbArgs(void)
|
||||
|
||||
@@ -579,13 +579,8 @@ assert : T_POP_ASSERT assert_type relocexpr
|
||||
}
|
||||
;
|
||||
|
||||
shift : T_POP_SHIFT { macro_ShiftCurrentArgs(); }
|
||||
| T_POP_SHIFT uconst
|
||||
{
|
||||
int32_t i = $2;
|
||||
while (i--)
|
||||
macro_ShiftCurrentArgs();
|
||||
}
|
||||
shift : T_POP_SHIFT { macro_ShiftCurrentArgs(1); }
|
||||
| T_POP_SHIFT const { macro_ShiftCurrentArgs($2); }
|
||||
;
|
||||
|
||||
load : T_POP_LOAD string ',' sectiontype sectorg sectattrs {
|
||||
|
||||
Reference in New Issue
Block a user