aboutsummaryrefslogtreecommitdiffstats
path: root/macros
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2025-12-15 15:16:40 -0500
committerGitHub <noreply@github.com>2025-12-15 15:16:40 -0500
commitd79c578abd993f7eee4e85462a8cd5b7c4e14646 (patch)
treedd89e07a471a12cd6eb731bf559d73940c07b444 /macros
parentComment more unreferenced local labels (#550) (diff)
downloadpokeyellow-d79c578abd993f7eee4e85462a8cd5b7c4e14646.tar.gz
pokeyellow-d79c578abd993f7eee4e85462a8cd5b7c4e14646.tar.xz
pokeyellow-d79c578abd993f7eee4e85462a8cd5b7c4e14646.zip
Specify a max item length for `list_start` (#552)
Diffstat (limited to 'macros')
-rw-r--r--macros/asserts.asm18
1 files changed, 14 insertions, 4 deletions
diff --git a/macros/asserts.asm b/macros/asserts.asm
index e2de1505..11e0ee99 100644
--- a/macros/asserts.asm
+++ b/macros/asserts.asm
@@ -4,8 +4,8 @@ MACRO? _redef_current_label
IF DEF(\1)
PURGE \1
ENDC
- IF _NARG == 3 + (\3)
- DEF \1 EQUS "\<_NARG>"
+ IF _NARG > 2
+ DEF \1 EQUS "\3"
ELIF STRLEN(#__SCOPE__)
IF {{__SCOPE__}} - @ == 0
DEF \1 EQUS #{__SCOPE__}
@@ -19,7 +19,8 @@ ENDM
MACRO? table_width
DEF CURRENT_TABLE_WIDTH = \1
- _redef_current_label CURRENT_TABLE_START, "._table_width\@", 2, \#
+ SHIFT
+ _redef_current_label CURRENT_TABLE_START, "._table_width\@", \#
ENDM
MACRO? assert_table_length
@@ -40,11 +41,20 @@ ENDM
MACRO? list_start
DEF list_index = 0
- _redef_current_label CURRENT_LIST_START, "._list_start\@", 1, \#
+ DEF list_item_length = 0
+ IF _NARG > 0
+ DEF list_item_length = \1
+ SHIFT
+ ENDC
+ _redef_current_label CURRENT_LIST_START, "._list_start\@", \#
ENDM
MACRO? li
ASSERT STRFIND(\1, "@") == -1, "String terminator \"@\" in list entry: \1"
+ IF list_item_length
+ ASSERT CHARLEN(\1) <= list_item_length, \
+ "List entry longer than {d:list_item_length} characters: \1"
+ ENDC
db \1, "@"
DEF list_index += 1
ENDM