Distinguish exprid and varid in --debug output

This commit is contained in:
Daniel Marjamäki 2020-11-28 15:41:07 +01:00
parent 5b89b179ec
commit f42c104b0d
2 changed files with 13 additions and 5 deletions

View File

@ -1136,14 +1136,14 @@ void Token::printOut(const char *title) const
{
if (title && title[0])
std::cout << "\n### " << title << " ###\n";
std::cout << stringifyList(stringifyOptions::forDebugExprId(), nullptr, nullptr) << std::endl;
std::cout << stringifyList(stringifyOptions::forPrintOut(), nullptr, nullptr) << std::endl;
}
void Token::printOut(const char *title, const std::vector<std::string> &fileNames) const
{
if (title && title[0])
std::cout << "\n### " << title << " ###\n";
std::cout << stringifyList(stringifyOptions::forDebugExprId(), &fileNames, nullptr) << std::endl;
std::cout << stringifyList(stringifyOptions::forPrintOut(), &fileNames, nullptr) << std::endl;
}
void Token::printLines(int lines) const
@ -1186,9 +1186,9 @@ void Token::stringify(std::ostream& os, const stringifyOptions& options) const
}
}
if (options.varid && mImpl->mVarId != 0)
os << '@' << mImpl->mVarId;
if (options.exprid && mImpl->mExprId != 0)
os << '@' << mImpl->mExprId;
os << "@" << (options.idtype ? "var" : "") << mImpl->mVarId;
else if (options.exprid && mImpl->mExprId != 0)
os << "@" << (options.idtype ? "expr" : "") << mImpl->mExprId;
}
void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) const

View File

@ -853,6 +853,7 @@ public:
struct stringifyOptions {
bool varid = false;
bool exprid = false;
bool idtype = false; // distinguish varid / exprid
bool attributes = false;
bool macro = false;
bool linenumbers = false;
@ -877,6 +878,13 @@ public:
options.exprid = true;
return options;
}
static stringifyOptions forPrintOut() {
stringifyOptions options = forDebug();
options.exprid = true;
options.varid = true;
options.idtype = true;
return options;
}
};
/**