mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Report only one error when invalid shift has argument
Not to mention that incrementing a variable in a loop is kinda dumb.
This commit is contained in:
@@ -29,7 +29,7 @@ uint32_t macro_GetUniqueID(void);
|
|||||||
char const *macro_GetUniqueIDStr(void);
|
char const *macro_GetUniqueIDStr(void);
|
||||||
void macro_SetUniqueID(uint32_t id);
|
void macro_SetUniqueID(uint32_t id);
|
||||||
uint32_t macro_UseNewUniqueID(void);
|
uint32_t macro_UseNewUniqueID(void);
|
||||||
void macro_ShiftCurrentArgs(void);
|
void macro_ShiftCurrentArgs(int32_t count);
|
||||||
uint32_t macro_NbArgs(void);
|
uint32_t macro_NbArgs(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -128,12 +128,15 @@ uint32_t macro_UseNewUniqueID(void)
|
|||||||
return maxUniqueID;
|
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");
|
error("Cannot shift macro arguments outside of a macro\n");
|
||||||
else if (macroArgs->shift != macroArgs->nbArgs)
|
else if (macroArgs->shift < macroArgs->nbArgs) {
|
||||||
macroArgs->shift++;
|
macroArgs->shift += count;
|
||||||
|
if (macroArgs->shift > macroArgs->nbArgs)
|
||||||
|
macroArgs->shift = macroArgs->nbArgs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t macro_NbArgs(void)
|
uint32_t macro_NbArgs(void)
|
||||||
|
|||||||
@@ -579,13 +579,8 @@ assert : T_POP_ASSERT assert_type relocexpr
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
shift : T_POP_SHIFT { macro_ShiftCurrentArgs(); }
|
shift : T_POP_SHIFT { macro_ShiftCurrentArgs(1); }
|
||||||
| T_POP_SHIFT uconst
|
| T_POP_SHIFT uconst { macro_ShiftCurrentArgs($2); }
|
||||||
{
|
|
||||||
int32_t i = $2;
|
|
||||||
while (i--)
|
|
||||||
macro_ShiftCurrentArgs();
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
load : T_POP_LOAD string ',' sectiontype sectorg sectattrs {
|
load : T_POP_LOAD string ',' sectiontype sectorg sectattrs {
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
shift
|
shift
|
||||||
|
shift 3
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
ERROR: shift-outside-macro.asm(1):
|
ERROR: shift-outside-macro.asm(1):
|
||||||
Cannot shift macro arguments outside of a macro
|
Cannot shift macro arguments outside of a macro
|
||||||
error: Assembly aborted (1 errors)!
|
ERROR: shift-outside-macro.asm(2):
|
||||||
|
Cannot shift macro arguments outside of a macro
|
||||||
|
error: Assembly aborted (2 errors)!
|
||||||
|
|||||||
Reference in New Issue
Block a user