Allow negative values to count macro arguments from the end (#1670)

This commit is contained in:
Rangi
2025-04-20 00:37:50 -04:00
committed by GitHub
parent df83bc31d2
commit 0b7cda9e0c
7 changed files with 91 additions and 11 deletions

View File

@@ -0,0 +1,21 @@
MACRO mac
for i, -1, -_NARG - 1, -1
println "{d:i}: \<i> == \<{d:i}>"
endr
; error cases
def i = 0
println "{d:i}: \<i> == \<{d:i}>"
def i = -_NARG - 1
println "{d:i}: \<i> == \<{d:i}>"
def i = $7fff_ffff
println "{d:i}: \<i> == \<{d:i}>"
; signed/unsigned difference error cases
def i = $8000_0000
println "{d:i}: \<i> == \<{d:i}>"
println "{u:i}: \<i> == \<{u:i}>"
def i = $ffff_ffff
println "{d:i}: \<i> == \<{d:i}>"
println "{u:i}: \<i> == \<{u:i}>"
ENDM
mac A, B, C, D, E, F, G