From 26d58ddbb98f43859960081a4643604916b18d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 16 Jun 2018 16:18:50 +0200 Subject: [PATCH] rename _astOperand1, _astOperand2, _astParent --- lib/token.cpp | 52 +++++++++++++++++++++++++-------------------------- lib/token.h | 26 +++++++++++++------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index 3aee2329b..47938fbaf 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -50,9 +50,9 @@ Token::Token(TokensFrontBack *tokensFrontBack) : _tokType(eNone), mFlags(0), _bits(0), - _astOperand1(nullptr), - _astOperand2(nullptr), - _astParent(nullptr), + mAstOperand1(nullptr), + mAstOperand2(nullptr), + mAstParent(nullptr), _originalName(nullptr), _valuetype(nullptr), _values(nullptr) @@ -1101,37 +1101,37 @@ std::string Token::stringifyList(bool varid) const void Token::astOperand1(Token *tok) { - if (_astOperand1) - _astOperand1->_astParent = nullptr; + if (mAstOperand1) + mAstOperand1->mAstParent = nullptr; // goto parent operator if (tok) { std::set visitedParents; - while (tok->_astParent) { - if (!visitedParents.insert(tok->_astParent).second) // #6838/#6726/#8352 avoid hang on garbage code + while (tok->mAstParent) { + if (!visitedParents.insert(tok->mAstParent).second) // #6838/#6726/#8352 avoid hang on garbage code throw InternalError(this, "Internal error. Token::astOperand1() cyclic dependency."); - tok = tok->_astParent; + tok = tok->mAstParent; } - tok->_astParent = this; + tok->mAstParent = this; } - _astOperand1 = tok; + mAstOperand1 = tok; } void Token::astOperand2(Token *tok) { - if (_astOperand2) - _astOperand2->_astParent = nullptr; + if (mAstOperand2) + mAstOperand2->mAstParent = nullptr; // goto parent operator if (tok) { std::set visitedParents; - while (tok->_astParent) { - //std::cout << tok << " -> " << tok->_astParent ; - if (!visitedParents.insert(tok->_astParent).second) // #6838/#6726 avoid hang on garbage code + while (tok->mAstParent) { + //std::cout << tok << " -> " << tok->mAstParent ; + if (!visitedParents.insert(tok->mAstParent).second) // #6838/#6726 avoid hang on garbage code throw InternalError(this, "Internal error. Token::astOperand2() cyclic dependency."); - tok = tok->_astParent; + tok = tok->mAstParent; } - tok->_astParent = this; + tok->mAstParent = this; } - _astOperand2 = tok; + mAstOperand2 = tok; } bool Token::isCalculation() const @@ -1179,9 +1179,9 @@ bool Token::isUnaryPreOp() const const Token *tokbefore = mPrevious; const Token *tokafter = mNext; for (int distance = 1; distance < 10 && tokbefore; distance++) { - if (tokbefore == _astOperand1) + if (tokbefore == mAstOperand1) return false; - if (tokafter == _astOperand1) + if (tokafter == mAstOperand1) return true; tokbefore = tokbefore->mPrevious; tokafter = tokafter->mPrevious; @@ -1298,7 +1298,7 @@ void Token::printAst(bool verbose, bool xml, std::ostream &out) const { std::set printed; for (const Token *tok = this; tok; tok = tok->next()) { - if (!tok->_astParent && tok->_astOperand1) { + if (!tok->mAstParent && tok->mAstOperand1) { if (printed.empty() && !xml) out << "\n\n##AST" << std::endl; else if (printed.find(tok) != printed.end()) @@ -1338,17 +1338,17 @@ std::string Token::astStringVerbose(const unsigned int indent1, const unsigned i ret += " \'" + _valuetype->str() + '\''; ret += '\n'; - if (_astOperand1) { + if (mAstOperand1) { unsigned int i1 = indent1, i2 = indent2 + 2; - if (indent1==indent2 && !_astOperand2) + if (indent1==indent2 && !mAstOperand2) i1 += 2; - ret += indent(indent1,indent2) + (_astOperand2 ? "|-" : "`-") + _astOperand1->astStringVerbose(i1,i2); + ret += indent(indent1,indent2) + (mAstOperand2 ? "|-" : "`-") + mAstOperand1->astStringVerbose(i1,i2); } - if (_astOperand2) { + if (mAstOperand2) { unsigned int i1 = indent1, i2 = indent2 + 2; if (indent1==indent2) i1 += 2; - ret += indent(indent1,indent2) + "`-" + _astOperand2->astStringVerbose(i1,i2); + ret += indent(indent1,indent2) + "`-" + mAstOperand2->astStringVerbose(i1,i2); } return ret; } diff --git a/lib/token.h b/lib/token.h index c335846e9..ea251b218 100644 --- a/lib/token.h +++ b/lib/token.h @@ -989,9 +989,9 @@ private: unsigned char _bits; // AST.. - Token *_astOperand1; - Token *_astOperand2; - Token *_astParent; + Token *mAstOperand1; + Token *mAstOperand2; + Token *mAstParent; // original name like size_t std::string* _originalName; @@ -1008,18 +1008,18 @@ public: void astOperand2(Token *tok); const Token * astOperand1() const { - return _astOperand1; + return mAstOperand1; } const Token * astOperand2() const { - return _astOperand2; + return mAstOperand2; } const Token * astParent() const { - return _astParent; + return mAstParent; } const Token *astTop() const { const Token *ret = this; - while (ret->_astParent) - ret = ret->_astParent; + while (ret->mAstParent) + ret = ret->mAstParent; return ret; } @@ -1033,7 +1033,7 @@ public: bool isCalculation() const; void clearAst() { - _astOperand1 = _astOperand2 = _astParent = nullptr; + mAstOperand1 = mAstOperand2 = mAstParent = nullptr; } void clearValueFlow() { @@ -1043,10 +1043,10 @@ public: std::string astString(const char *sep = "") const { std::string ret; - if (_astOperand1) - ret = _astOperand1->astString(sep); - if (_astOperand2) - ret += _astOperand2->astString(sep); + if (mAstOperand1) + ret = mAstOperand1->astString(sep); + if (mAstOperand2) + ret += mAstOperand2->astString(sep); return ret + sep + _str; }