mirror of
https://github.com/gbdev/rgbds.git
synced 2026-10-04 03:05:36 +00:00
Fix backtraces for REPT nodes with quiet non-REPT ancestors (#2196)
This commit is contained in:
1 parent
9095c5b320
commit
d73a05aa78
5 files changed
+53
-12
No files matched your search
+16
-6
@@ -86,13 +86,23 @@ void FileStackNode::printBacktrace(uint32_t curLineNo) const {
|
||||
traceNodes.reserve(items.size());
|
||||
for (auto &[node, itemLineNo] : reversed(items)) {
|
||||
if (std::holds_alternative<std::vector<uint32_t>>(node->data)) {
|
||||
assume(!traceNodes.empty()); // REPT nodes use their parent's name
|
||||
std::string reptName = traceNodes.back().first;
|
||||
if (std::vector<uint32_t> const &nodeIters = node->iters(); !nodeIters.empty()) {
|
||||
reptName.append(NODE_SEPARATOR REPT_NODE_PREFIX);
|
||||
reptName.append(std::to_string(nodeIters.front()));
|
||||
// REPT nodes use their first non-REPT parent's name (which may be a quiet node and
|
||||
// thus not in `traceNodes`), followed by their REPT parents' iteration counts,
|
||||
// followed by their own iteration count.
|
||||
std::string reptName;
|
||||
for (FileStackNode const *ancestor = node->parent.get();;
|
||||
ancestor = ancestor->parent.get()) {
|
||||
assume(ancestor != nullptr); // The top level context cannot be a REPT
|
||||
if (ancestor->type != NODE_REPT) {
|
||||
reptName.append(ancestor->name());
|
||||
break;
|
||||
}
|
||||
}
|
||||
traceNodes.emplace_back(reptName, itemLineNo);
|
||||
for (uint32_t iter : reversed(node->iters())) {
|
||||
reptName.append(NODE_SEPARATOR REPT_NODE_PREFIX);
|
||||
reptName.append(std::to_string(iter));
|
||||
}
|
||||
traceNodes.emplace_back(std::move(reptName), itemLineNo);
|
||||
} else {
|
||||
traceNodes.emplace_back(node->name(), itemLineNo);
|
||||
}
|
||||
|
||||
+16
-6
@@ -41,13 +41,23 @@ void FileStackNode::printBacktrace(uint32_t curLineNo) const {
|
||||
traceNodes.reserve(items.size());
|
||||
for (auto &[node, itemLineNo] : reversed(items)) {
|
||||
if (std::holds_alternative<std::vector<uint32_t>>(node->data)) {
|
||||
assume(!traceNodes.empty()); // REPT nodes use their parent's name
|
||||
std::string reptName = traceNodes.back().first;
|
||||
if (std::vector<uint32_t> const &nodeIters = node->iters(); !nodeIters.empty()) {
|
||||
reptName.append(NODE_SEPARATOR REPT_NODE_PREFIX);
|
||||
reptName.append(std::to_string(nodeIters.back()));
|
||||
// REPT nodes use their first non-REPT parent's name (which may be a quiet node and
|
||||
// thus not in `traceNodes`), followed by their REPT parents' iteration counts,
|
||||
// followed by their own iteration count.
|
||||
std::string reptName;
|
||||
for (FileStackNode const *ancestor = node->parent;; ancestor = ancestor->parent) {
|
||||
// The top level context cannot be a REPT (guaranteed by `readFileStackNode`)
|
||||
assume(ancestor != nullptr);
|
||||
if (ancestor->type != NODE_REPT) {
|
||||
reptName.append(ancestor->name());
|
||||
break;
|
||||
}
|
||||
}
|
||||
traceNodes.emplace_back(reptName, itemLineNo);
|
||||
for (uint32_t iter : node->iters()) {
|
||||
reptName.append(NODE_SEPARATOR REPT_NODE_PREFIX);
|
||||
reptName.append(std::to_string(iter));
|
||||
}
|
||||
traceNodes.emplace_back(std::move(reptName), itemLineNo);
|
||||
} else {
|
||||
traceNodes.emplace_back(node->name(), itemLineNo);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
INCLUDE "rept-node-names.inc"
|
||||
quiet
|
||||
loud
|
||||
@@ -0,0 +1,8 @@
|
||||
warning: $0 [-Wuser]
|
||||
at rept-node-names.inc::quiet::REPT~1(3) <- rept-node-names.asm(2)
|
||||
warning: $1 [-Wuser]
|
||||
at rept-node-names.inc::quiet::REPT~2(3) <- rept-node-names.asm(2)
|
||||
warning: $0 [-Wuser]
|
||||
at rept-node-names.inc::loud::REPT~1(8) <- rept-node-names.inc::loud(7) <- rept-node-names.asm(3)
|
||||
warning: $1 [-Wuser]
|
||||
at rept-node-names.inc::loud::REPT~2(8) <- rept-node-names.inc::loud(7) <- rept-node-names.asm(3)
|
||||
@@ -0,0 +1,10 @@
|
||||
MACRO? quiet
|
||||
FOR i, 2
|
||||
WARN "{i}"
|
||||
ENDR
|
||||
ENDM
|
||||
MACRO loud
|
||||
FOR i, 2
|
||||
WARN "{i}"
|
||||
ENDR
|
||||
ENDM
|
||||
Reference in new issue
Block a user