Files
marzipan/src/labels/snapshots/zasm__labels__process__test__local_labels.snap
T
cmounce 84cec642a3 Use section numbers when resolving local labels
This changes the semantics of local labels. Previously, local labels
were just shorthand for writing out `name.local`, which meant if there
were multiple sections named "name", there could potentially be name
collisions.

This commit adds a unique numeric suffix to each section's ID string.
This guarantees that locals in one section won't interfere with those in
a different section.
2025-06-21 22:14:02 -07:00

56 lines
713 B
Plaintext

---
source: src/labels/process.rs
expression: board_to_text(board)
---
'Slightly contrived example: two routines
'using the same local label ".loop"
:run_w
#walk w
:_loop
#try w stop
#_loop
'
:run_e
#walk e
:_loop0
#try e stop
#_loop0
'
:stop
#walk i
---
'Using locals before any globals are defined
:_loop1
#take gems 1 _break
#_loop1
:_break
---
'Multiple sections with the same name
#end
:touch
Trying to sell you some ammo...
#take gems 10 _skip
#give ammo 10
:_skip
#zap touch
#end
:touch
Trying to sell you some torches...
#take gems 15 _skip0
#give torches 5
:_skip0
#restore touch
---
'Multiple locals with the same name
#end
:repeat3
:_z
:_z
:_z
#take gems 1 _skip1
#give score 1
:_skip1
#zap _z
#_z
:_z