mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
@@ -351,8 +351,10 @@ void fstk_RunInclude(char const *path)
|
||||
if (!contextStack->lexerState)
|
||||
fatalerror("Failed to set up lexer for file include\n");
|
||||
lexer_SetStateAtEOL(contextStack->lexerState);
|
||||
// We're back at top-level, so most things are reset
|
||||
contextStack->uniqueID = macro_UndefUniqueID();
|
||||
// We're back at top-level, so most things are reset,
|
||||
// but not the unique ID, since INCLUDE may be inside a
|
||||
// MACRO or REPT/FOR loop
|
||||
contextStack->uniqueID = contextStack->parent->uniqueID;
|
||||
}
|
||||
|
||||
// Similar to `fstk_RunInclude`, but not subject to `-MG`, and
|
||||
|
||||
24
test/asm/include-unique-id.asm
Normal file
24
test/asm/include-unique-id.asm
Normal file
@@ -0,0 +1,24 @@
|
||||
MACRO mac
|
||||
println "outer mac: \@ (\#)"
|
||||
INCLUDE "include-unique-id.inc"
|
||||
ENDM
|
||||
|
||||
DEF state = 1
|
||||
mac hello, world
|
||||
mac goodbye, world
|
||||
|
||||
REPT 2
|
||||
DEF state = 2
|
||||
println "outer rept before: \@"
|
||||
INCLUDE "include-unique-id.inc"
|
||||
|
||||
FOR n, 3
|
||||
DEF state = 3
|
||||
println "outer for: \@ ({n})"
|
||||
INCLUDE "include-unique-id.inc"
|
||||
ENDR
|
||||
|
||||
DEF state = 4
|
||||
println "outer rept after: \@"
|
||||
INCLUDE "include-unique-id.inc"
|
||||
ENDR
|
||||
0
test/asm/include-unique-id.err
Normal file
0
test/asm/include-unique-id.err
Normal file
9
test/asm/include-unique-id.inc
Normal file
9
test/asm/include-unique-id.inc
Normal file
@@ -0,0 +1,9 @@
|
||||
IF state == 1
|
||||
println "inner mac: \@ (\#)"
|
||||
ELIF state == 2
|
||||
println "inner rept before: \@"
|
||||
ELIF state == 3
|
||||
println "inner for: \@ ({n})"
|
||||
ELIF state == 4
|
||||
println "inner rept after: \@"
|
||||
ENDC
|
||||
24
test/asm/include-unique-id.out
Normal file
24
test/asm/include-unique-id.out
Normal file
@@ -0,0 +1,24 @@
|
||||
outer mac: _u1 (hello,world)
|
||||
inner mac: _u1 (hello,world)
|
||||
outer mac: _u2 (goodbye,world)
|
||||
inner mac: _u2 (goodbye,world)
|
||||
outer rept before: _u3
|
||||
inner rept before: _u3
|
||||
outer for: _u4 ($0)
|
||||
inner for: _u4 ($0)
|
||||
outer for: _u5 ($1)
|
||||
inner for: _u5 ($1)
|
||||
outer for: _u6 ($2)
|
||||
inner for: _u6 ($2)
|
||||
outer rept after: _u3
|
||||
inner rept after: _u3
|
||||
outer rept before: _u7
|
||||
inner rept before: _u7
|
||||
outer for: _u8 ($0)
|
||||
inner for: _u8 ($0)
|
||||
outer for: _u9 ($1)
|
||||
inner for: _u9 ($1)
|
||||
outer for: _u10 ($2)
|
||||
inner for: _u10 ($2)
|
||||
outer rept after: _u7
|
||||
inner rept after: _u7
|
||||
Reference in New Issue
Block a user