mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Implement . string constant for the current label scope (#1499)
This commit is contained in:
@@ -11,5 +11,23 @@ REDEF _NARG = 78
|
||||
DEF _NARG EQUS "hello"
|
||||
REDEF _NARG EQUS "world"
|
||||
|
||||
SECTION "test", ROM0
|
||||
SECTION "_NARG", ROM0
|
||||
_NARG:
|
||||
ENDSECTION
|
||||
|
||||
ASSERT !DEF(.)
|
||||
|
||||
PURGE .
|
||||
|
||||
DEF . EQU 12
|
||||
REDEF . EQU 34
|
||||
|
||||
DEF . = 56
|
||||
REDEF . = 78
|
||||
|
||||
DEF . EQUS "hello"
|
||||
REDEF . EQUS "world"
|
||||
|
||||
SECTION ".", ROM0
|
||||
.:
|
||||
ENDSECTION
|
||||
|
||||
@@ -14,4 +14,20 @@ error: builtin-reserved.asm(12):
|
||||
'_NARG' is reserved for a built-in symbol
|
||||
error: builtin-reserved.asm(15):
|
||||
'_NARG' is reserved for a built-in symbol
|
||||
error: Assembly aborted (8 errors)!
|
||||
error: builtin-reserved.asm(20):
|
||||
'.' not defined
|
||||
error: builtin-reserved.asm(22):
|
||||
'.' is reserved for a built-in symbol
|
||||
error: builtin-reserved.asm(23):
|
||||
'.' is reserved for a built-in symbol
|
||||
error: builtin-reserved.asm(25):
|
||||
'.' is reserved for a built-in symbol
|
||||
error: builtin-reserved.asm(26):
|
||||
'.' is reserved for a built-in symbol
|
||||
error: builtin-reserved.asm(28):
|
||||
'.' is reserved for a built-in symbol
|
||||
error: builtin-reserved.asm(29):
|
||||
'.' is reserved for a built-in symbol
|
||||
error: builtin-reserved.asm(32):
|
||||
"." has no value outside of a label scope
|
||||
error: Assembly aborted (16 errors)!
|
||||
|
||||
12
test/asm/label-scope.asm
Normal file
12
test/asm/label-scope.asm
Normal file
@@ -0,0 +1,12 @@
|
||||
ASSERT !DEF(@) && !DEF(.)
|
||||
|
||||
PURGE @, .
|
||||
|
||||
SECTION "test", ROM0[42]
|
||||
Foobar:
|
||||
|
||||
PURGE @, .
|
||||
|
||||
ASSERT DEF(@) && DEF(.) && DEF(Foobar)
|
||||
|
||||
PRINTLN "PC: {#05X:@}; label scope: \"{.}\"; {.}: {#05X:{.}}"
|
||||
9
test/asm/label-scope.err
Normal file
9
test/asm/label-scope.err
Normal file
@@ -0,0 +1,9 @@
|
||||
error: label-scope.asm(3):
|
||||
'@' not defined
|
||||
error: label-scope.asm(3):
|
||||
'.' not defined
|
||||
error: label-scope.asm(8):
|
||||
Built-in symbol '@' cannot be purged
|
||||
error: label-scope.asm(8):
|
||||
Built-in symbol '.' cannot be purged
|
||||
error: Assembly aborted (4 errors)!
|
||||
1
test/asm/label-scope.out
Normal file
1
test/asm/label-scope.out
Normal file
@@ -0,0 +1 @@
|
||||
PC: $002A; label scope: "Foobar"; Foobar: $002A
|
||||
@@ -2,4 +2,5 @@ section "period", rom0
|
||||
|
||||
global1: db 1
|
||||
.local db 2
|
||||
. db 3
|
||||
. db 3 ; this...
|
||||
global1 db 4 ; ...expands to this
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
error: period.asm(5):
|
||||
syntax error, unexpected .
|
||||
error: Assembly aborted (1 error)!
|
||||
syntax error, unexpected DB, expecting : or ::
|
||||
error: period.asm(6):
|
||||
syntax error, unexpected DB, expecting : or ::
|
||||
error: Assembly aborted (2 errors)!
|
||||
|
||||
@@ -3,6 +3,11 @@ assert !DEF(@)
|
||||
println @
|
||||
println "{@}?"
|
||||
|
||||
; not inside a label scope
|
||||
assert !DEF(.)
|
||||
println .
|
||||
println "{.}?"
|
||||
|
||||
; not inside a macro
|
||||
assert !DEF(_NARG)
|
||||
println _NARG
|
||||
@@ -13,6 +18,11 @@ assert DEF(@)
|
||||
println @
|
||||
println "{@}!"
|
||||
|
||||
LabelScope:
|
||||
assert DEF(.)
|
||||
println .
|
||||
println "{.}!"
|
||||
|
||||
MACRO m
|
||||
assert DEF(_NARG)
|
||||
println _NARG
|
||||
|
||||
@@ -3,7 +3,11 @@ error: undefined-builtins.asm(3):
|
||||
error: undefined-builtins.asm(4):
|
||||
Interpolated symbol "@" does not exist
|
||||
error: undefined-builtins.asm(8):
|
||||
_NARG has no value outside of a macro
|
||||
"." has no value outside of a label scope
|
||||
error: undefined-builtins.asm(9):
|
||||
Interpolated symbol "." does not exist
|
||||
error: undefined-builtins.asm(13):
|
||||
_NARG has no value outside of a macro
|
||||
error: undefined-builtins.asm(14):
|
||||
Interpolated symbol "_NARG" does not exist
|
||||
error: Assembly aborted (4 errors)!
|
||||
error: Assembly aborted (6 errors)!
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
$0
|
||||
?
|
||||
|
||||
?
|
||||
$0
|
||||
?
|
||||
$42
|
||||
$42!
|
||||
$42
|
||||
LabelScope!
|
||||
$3
|
||||
$3!
|
||||
|
||||
Reference in New Issue
Block a user