From f42c104b0de7524aaf63721cc7e40a3dc8a75de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 28 Nov 2020 15:41:07 +0100 Subject: [PATCH] Distinguish exprid and varid in --debug output --- lib/token.cpp | 10 +++++----- lib/token.h | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index afb9ad8a1..f9c7f7f63 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -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 &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 diff --git a/lib/token.h b/lib/token.h index 3a094c11b..3d72dae7f 100644 --- a/lib/token.h +++ b/lib/token.h @@ -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; + } }; /**