-
Notifications
You must be signed in to change notification settings - Fork 0
Description
See gbdev/rgbds#342 and #12.
Add a LOCAL keyword that acts as a modifier on EQU, EQUS, SET, MACRO, and label declarations, causing them to be scoped to the current file. This means if the file is included with INCLUDE, all defines, macros, and labels marked as local are automatically purged and any previous symbols with the same names are available again.
Examples:
LOCAL MacroName : MACRO
; ...
ENDM
LOCAL foo EQU $F
LOCAL bar EQUS "baz"
LOCAL Foo.bar:
This could potentially supersede #12 as the mechanism for introducing lexical scoping. In that case, there needs to be a way to file-scope a definition that's within a macro. Not sure about syntax but possibly something like GLOBAL LOCAL.
From an implementation perspective, I think the cleanest way to handle the implied 'symbol stacks' in hgbasm is to make the symbol structs recursive with a nullable previousSymbol field, so all other symbol-handling code can remain as simple as they are and only the declaration and purging logic need to deal with it.