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.
This commit is contained in:
2025-06-21 21:58:55 -07:00
parent 34f808e042
commit 84cec642a3
3 changed files with 76 additions and 3 deletions
+36
View File
@@ -14,3 +14,39 @@
'
:stop
#walk i
---
'Using locals before any globals are defined
:.loop
#take gems 1 .break
#.loop
:.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 .skip
#give torches 5
:.skip
#restore touch
---
'Multiple locals with the same name
#end
:repeat3
:.z
:.z
:.z
#take gems 1 .skip
#give score 1
:.skip
#zap .z
#.z
:.z