mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Implement ? suffix to "quiet" a context and exclude it from backtraces (#1800)
This commit is contained in:
@@ -9,6 +9,16 @@
|
||||
using TraceNode = std::pair<std::string, uint32_t>;
|
||||
|
||||
static std::vector<TraceNode> backtrace(FileStackNode const &node, uint32_t curLineNo) {
|
||||
if (node.isQuiet && !tracing.loud) {
|
||||
if (node.parent) {
|
||||
// Quiet REPT nodes will pass their interior line number up to their parent,
|
||||
// which is more precise than the parent's own line number (since that will be
|
||||
// the line number of the "REPT?" or "FOR?" itself).
|
||||
return backtrace(*node.parent, node.type == NODE_REPT ? curLineNo : node.lineNo);
|
||||
}
|
||||
return {}; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
if (!node.parent) {
|
||||
assume(node.type != NODE_REPT && std::holds_alternative<std::string>(node.data));
|
||||
return {
|
||||
|
||||
@@ -105,14 +105,12 @@ static void readFileStackNode(
|
||||
tryReadLong(
|
||||
node.lineNo, file, "%s: Cannot read node #%" PRIu32 "'s line number: %s", fileName, nodeID
|
||||
);
|
||||
tryGetc(
|
||||
FileStackNodeType,
|
||||
node.type,
|
||||
file,
|
||||
"%s: Cannot read node #%" PRIu32 "'s type: %s",
|
||||
fileName,
|
||||
nodeID
|
||||
);
|
||||
|
||||
uint8_t type;
|
||||
tryGetc(uint8_t, type, file, "%s: Cannot read node #%" PRIu32 "'s type: %s", fileName, nodeID);
|
||||
node.type = static_cast<FileStackNodeType>(type & ~(1 << FSTACKNODE_QUIET_BIT));
|
||||
node.isQuiet = (type & (1 << FSTACKNODE_QUIET_BIT)) != 0;
|
||||
|
||||
switch (node.type) {
|
||||
case NODE_FILE:
|
||||
case NODE_MACRO:
|
||||
@@ -318,14 +316,14 @@ static void readSection(
|
||||
tryGetc(
|
||||
uint8_t, byte, file, "%s: Cannot read \"%s\"'s type: %s", fileName, section.name.c_str()
|
||||
);
|
||||
if (uint8_t type = byte & 0x3F; type >= SECTTYPE_INVALID) {
|
||||
if (uint8_t type = byte & SECTTYPE_TYPE_MASK; type >= SECTTYPE_INVALID) {
|
||||
fatal("\"%s\" has unknown section type 0x%02x", section.name.c_str(), type);
|
||||
} else {
|
||||
section.type = SectionType(type);
|
||||
}
|
||||
if (byte >> 7) {
|
||||
if (byte & (1 << SECTTYPE_UNION_BIT)) {
|
||||
section.modifier = SECTION_UNION;
|
||||
} else if (byte >> 6) {
|
||||
} else if (byte & (1 << SECTTYPE_FRAGMENT_BIT)) {
|
||||
section.modifier = SECTION_FRAGMENT;
|
||||
} else {
|
||||
section.modifier = SECTION_NORMAL;
|
||||
@@ -458,6 +456,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) {
|
||||
nodes[fileID].push_back({
|
||||
.type = NODE_FILE,
|
||||
.data = std::variant<std::monostate, std::vector<uint32_t>, std::string>(fileName),
|
||||
.isQuiet = false,
|
||||
.parent = nullptr,
|
||||
.lineNo = 0,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user