mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix fstack traces for macro nodes (#1318)
Since the lexer rewrite, MACRO nodes' fstack traces have not included their parent REPT nodes' names.
This commit is contained in:
@@ -385,22 +385,6 @@ void fstk_RunMacro(char const *macroName, struct MacroArgs *args)
|
|||||||
}
|
}
|
||||||
contextStack->macroArgs = macro_GetCurrentArgs();
|
contextStack->macroArgs = macro_GetCurrentArgs();
|
||||||
|
|
||||||
// Compute total length of this node's name: <base name>::<macro>
|
|
||||||
size_t reptNameLen = 0;
|
|
||||||
struct FileStackNode const *node = macro->src;
|
|
||||||
|
|
||||||
if (node->type == NODE_REPT) {
|
|
||||||
struct FileStackReptNode const *reptNode = (struct FileStackReptNode const *)node;
|
|
||||||
|
|
||||||
// 4294967295 = 2^32 - 1, aka UINT32_MAX
|
|
||||||
reptNameLen += reptNode->iters->size() * strlen("::REPT~4294967295");
|
|
||||||
// Look for next named node
|
|
||||||
do {
|
|
||||||
node = node->parent;
|
|
||||||
} while (node->type == NODE_REPT);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct FileStackNamedNode const *baseNode = (struct FileStackNamedNode const *)node;
|
|
||||||
struct FileStackNamedNode *fileInfo = (struct FileStackNamedNode *)malloc(sizeof(*fileInfo));
|
struct FileStackNamedNode *fileInfo = (struct FileStackNamedNode *)malloc(sizeof(*fileInfo));
|
||||||
|
|
||||||
if (fileInfo)
|
if (fileInfo)
|
||||||
@@ -412,10 +396,14 @@ void fstk_RunMacro(char const *macroName, struct MacroArgs *args)
|
|||||||
fileInfo->node.type = NODE_MACRO;
|
fileInfo->node.type = NODE_MACRO;
|
||||||
|
|
||||||
// Print the name...
|
// Print the name...
|
||||||
fileInfo->name->reserve(baseNode->name->length() + reptNameLen + 2 + strlen(macro->name));
|
for (struct FileStackNode const *node = macro->src; node; node = node->parent) {
|
||||||
fileInfo->name->append(*baseNode->name);
|
if (node->type != NODE_REPT) {
|
||||||
if (node->type == NODE_REPT) {
|
fileInfo->name->append(*((struct FileStackNamedNode const *)node)->name);
|
||||||
struct FileStackReptNode const *reptNode = (struct FileStackReptNode const *)node;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (macro->src->type == NODE_REPT) {
|
||||||
|
struct FileStackReptNode const *reptNode = (struct FileStackReptNode const *)macro->src;
|
||||||
|
|
||||||
for (uint32_t i = reptNode->iters->size(); i--; ) {
|
for (uint32_t i = reptNode->iters->size(); i--; ) {
|
||||||
char buf[sizeof("::REPT~4294967295")]; // UINT32_MAX
|
char buf[sizeof("::REPT~4294967295")]; // UINT32_MAX
|
||||||
|
|||||||
41
test/asm/rept-macro-fstack-trace.asm
Normal file
41
test/asm/rept-macro-fstack-trace.asm
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
MACRO outer
|
||||||
|
DEF it = 1
|
||||||
|
DEF n = 0
|
||||||
|
REPT 4
|
||||||
|
IF n % 2 == 0
|
||||||
|
IF DEF(inner)
|
||||||
|
PURGE inner
|
||||||
|
ENDC
|
||||||
|
DEF s EQUS "\nMACRO inner\nREPT 2\nREPT 2\nWARN \"round \{d:it\}\"\nDEF it += 1\nENDR\nENDR\nENDM"
|
||||||
|
s
|
||||||
|
PURGE s
|
||||||
|
ENDC
|
||||||
|
inner
|
||||||
|
DEF n += 1
|
||||||
|
ENDR
|
||||||
|
ENDM
|
||||||
|
REPT 1
|
||||||
|
outer
|
||||||
|
ENDR
|
||||||
|
|
||||||
|
MACRO foo
|
||||||
|
REPT 1
|
||||||
|
REPT 1
|
||||||
|
WARN "round {d:it}"
|
||||||
|
DEF it += 1
|
||||||
|
ENDR
|
||||||
|
ENDR
|
||||||
|
ENDM
|
||||||
|
REPT 1
|
||||||
|
REPT 1
|
||||||
|
MACRO bar
|
||||||
|
REPT 2
|
||||||
|
REPT 2
|
||||||
|
foo
|
||||||
|
ENDR
|
||||||
|
ENDR
|
||||||
|
ENDM
|
||||||
|
bar
|
||||||
|
ENDR
|
||||||
|
ENDR
|
||||||
|
|
||||||
40
test/asm/rept-macro-fstack-trace.err
Normal file
40
test/asm/rept-macro-fstack-trace.err
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~1(20) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1(13): [-Wuser]
|
||||||
|
round 1
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~1(20) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~2(13): [-Wuser]
|
||||||
|
round 2
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~1(20) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~1(13): [-Wuser]
|
||||||
|
round 3
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~1(20) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2(13): [-Wuser]
|
||||||
|
round 4
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~2(13) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~1(13): [-Wuser]
|
||||||
|
round 5
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~2(13) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~1::REPT~2(13): [-Wuser]
|
||||||
|
round 6
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~2(13) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~1(13): [-Wuser]
|
||||||
|
round 7
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~2(13) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~1::inner::REPT~2::REPT~2(13): [-Wuser]
|
||||||
|
round 8
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~3(20) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1(13): [-Wuser]
|
||||||
|
round 9
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~3(20) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~2(13): [-Wuser]
|
||||||
|
round 10
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~3(20) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~1(13): [-Wuser]
|
||||||
|
round 11
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~3(20) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2(13): [-Wuser]
|
||||||
|
round 12
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~4(13) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~1(13): [-Wuser]
|
||||||
|
round 13
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~4(13) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~1::REPT~2(13): [-Wuser]
|
||||||
|
round 14
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~4(13) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~1(13): [-Wuser]
|
||||||
|
round 15
|
||||||
|
warning: rept-macro-fstack-trace.asm(17) -> rept-macro-fstack-trace.asm::REPT~1(18) -> rept-macro-fstack-trace.asm::outer(4) -> rept-macro-fstack-trace.asm::outer::REPT~4(13) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner(11) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2(12) -> rept-macro-fstack-trace.asm::outer::REPT~3::inner::REPT~2::REPT~2(13): [-Wuser]
|
||||||
|
round 16
|
||||||
|
warning: rept-macro-fstack-trace.asm(29) -> rept-macro-fstack-trace.asm::REPT~1(30) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1(38) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1(33) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1::REPT~1(34) -> rept-macro-fstack-trace.asm::foo(22) -> rept-macro-fstack-trace.asm::foo::REPT~1(23) -> rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24): [-Wuser]
|
||||||
|
round 17
|
||||||
|
warning: rept-macro-fstack-trace.asm(29) -> rept-macro-fstack-trace.asm::REPT~1(30) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1(38) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1(33) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~1::REPT~2(34) -> rept-macro-fstack-trace.asm::foo(22) -> rept-macro-fstack-trace.asm::foo::REPT~1(23) -> rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24): [-Wuser]
|
||||||
|
round 18
|
||||||
|
warning: rept-macro-fstack-trace.asm(29) -> rept-macro-fstack-trace.asm::REPT~1(30) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1(38) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2(33) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2::REPT~1(34) -> rept-macro-fstack-trace.asm::foo(22) -> rept-macro-fstack-trace.asm::foo::REPT~1(23) -> rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24): [-Wuser]
|
||||||
|
round 19
|
||||||
|
warning: rept-macro-fstack-trace.asm(29) -> rept-macro-fstack-trace.asm::REPT~1(30) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1(38) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar(32) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2(33) -> rept-macro-fstack-trace.asm::REPT~1::REPT~1::bar::REPT~2::REPT~2(34) -> rept-macro-fstack-trace.asm::foo(22) -> rept-macro-fstack-trace.asm::foo::REPT~1(23) -> rept-macro-fstack-trace.asm::foo::REPT~1::REPT~1(24): [-Wuser]
|
||||||
|
round 20
|
||||||
Reference in New Issue
Block a user