rename _previous and _next
This commit is contained in:
parent
363f4ca939
commit
435aa70c3d
|
@ -37,8 +37,8 @@ const std::list<ValueFlow::Value> Token::emptyValueList;
|
||||||
|
|
||||||
Token::Token(TokensFrontBack *tokensFrontBack) :
|
Token::Token(TokensFrontBack *tokensFrontBack) :
|
||||||
_tokensFrontBack(tokensFrontBack),
|
_tokensFrontBack(tokensFrontBack),
|
||||||
_next(nullptr),
|
mNext(nullptr),
|
||||||
_previous(nullptr),
|
mPrevious(nullptr),
|
||||||
_link(nullptr),
|
_link(nullptr),
|
||||||
_scope(nullptr),
|
_scope(nullptr),
|
||||||
_function(nullptr), // Initialize whole union
|
_function(nullptr), // Initialize whole union
|
||||||
|
@ -205,64 +205,64 @@ std::string Token::strValue() const
|
||||||
|
|
||||||
void Token::deleteNext(unsigned long index)
|
void Token::deleteNext(unsigned long index)
|
||||||
{
|
{
|
||||||
while (_next && index) {
|
while (mNext && index) {
|
||||||
Token *n = _next;
|
Token *n = mNext;
|
||||||
|
|
||||||
// #8154 we are about to be unknown -> destroy the link to us
|
// #8154 we are about to be unknown -> destroy the link to us
|
||||||
if (n->_link && n->_link->_link == n)
|
if (n->_link && n->_link->_link == n)
|
||||||
n->_link->link(nullptr);
|
n->_link->link(nullptr);
|
||||||
|
|
||||||
_next = n->next();
|
mNext = n->next();
|
||||||
delete n;
|
delete n;
|
||||||
--index;
|
--index;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_next)
|
if (mNext)
|
||||||
_next->previous(this);
|
mNext->previous(this);
|
||||||
else if (_tokensFrontBack)
|
else if (_tokensFrontBack)
|
||||||
_tokensFrontBack->back = this;
|
_tokensFrontBack->back = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::deletePrevious(unsigned long index)
|
void Token::deletePrevious(unsigned long index)
|
||||||
{
|
{
|
||||||
while (_previous && index) {
|
while (mPrevious && index) {
|
||||||
Token *p = _previous;
|
Token *p = mPrevious;
|
||||||
|
|
||||||
// #8154 we are about to be unknown -> destroy the link to us
|
// #8154 we are about to be unknown -> destroy the link to us
|
||||||
if (p->_link && p->_link->_link == p)
|
if (p->_link && p->_link->_link == p)
|
||||||
p->_link->link(nullptr);
|
p->_link->link(nullptr);
|
||||||
|
|
||||||
_previous = p->previous();
|
mPrevious = p->previous();
|
||||||
delete p;
|
delete p;
|
||||||
--index;
|
--index;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_previous)
|
if (mPrevious)
|
||||||
_previous->next(this);
|
mPrevious->next(this);
|
||||||
else if (_tokensFrontBack)
|
else if (_tokensFrontBack)
|
||||||
_tokensFrontBack->front = this;
|
_tokensFrontBack->front = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::swapWithNext()
|
void Token::swapWithNext()
|
||||||
{
|
{
|
||||||
if (_next) {
|
if (mNext) {
|
||||||
std::swap(_str, _next->_str);
|
std::swap(_str, mNext->_str);
|
||||||
std::swap(_tokType, _next->_tokType);
|
std::swap(_tokType, mNext->_tokType);
|
||||||
std::swap(mFlags, _next->mFlags);
|
std::swap(mFlags, mNext->mFlags);
|
||||||
std::swap(_varId, _next->_varId);
|
std::swap(_varId, mNext->_varId);
|
||||||
std::swap(_fileIndex, _next->_fileIndex);
|
std::swap(_fileIndex, mNext->_fileIndex);
|
||||||
std::swap(_linenr, _next->_linenr);
|
std::swap(_linenr, mNext->_linenr);
|
||||||
if (_next->_link)
|
if (mNext->_link)
|
||||||
_next->_link->_link = this;
|
mNext->_link->_link = this;
|
||||||
if (this->_link)
|
if (this->_link)
|
||||||
this->_link->_link = _next;
|
this->_link->_link = mNext;
|
||||||
std::swap(_link, _next->_link);
|
std::swap(_link, mNext->_link);
|
||||||
std::swap(_scope, _next->_scope);
|
std::swap(_scope, mNext->_scope);
|
||||||
std::swap(_function, _next->_function);
|
std::swap(_function, mNext->_function);
|
||||||
std::swap(_originalName, _next->_originalName);
|
std::swap(_originalName, mNext->_originalName);
|
||||||
std::swap(_values, _next->_values);
|
std::swap(_values, mNext->_values);
|
||||||
std::swap(_valuetype, _next->_valuetype);
|
std::swap(_valuetype, mNext->_valuetype);
|
||||||
std::swap(_progressValue, _next->_progressValue);
|
std::swap(_progressValue, mNext->_progressValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,16 +294,16 @@ void Token::takeData(Token *fromToken)
|
||||||
|
|
||||||
void Token::deleteThis()
|
void Token::deleteThis()
|
||||||
{
|
{
|
||||||
if (_next) { // Copy next to this and delete next
|
if (mNext) { // Copy next to this and delete next
|
||||||
takeData(_next);
|
takeData(mNext);
|
||||||
_next->link(nullptr); // mark as unlinked
|
mNext->link(nullptr); // mark as unlinked
|
||||||
deleteNext();
|
deleteNext();
|
||||||
} else if (_previous && _previous->_previous) { // Copy previous to this and delete previous
|
} else if (mPrevious && mPrevious->mPrevious) { // Copy previous to this and delete previous
|
||||||
takeData(_previous);
|
takeData(mPrevious);
|
||||||
|
|
||||||
Token* toDelete = _previous;
|
Token* toDelete = mPrevious;
|
||||||
_previous = _previous->_previous;
|
mPrevious = mPrevious->mPrevious;
|
||||||
_previous->_next = this;
|
mPrevious->mNext = this;
|
||||||
|
|
||||||
delete toDelete;
|
delete toDelete;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1176,15 +1176,15 @@ bool Token::isUnaryPreOp() const
|
||||||
return false;
|
return false;
|
||||||
if (!Token::Match(this, "++|--"))
|
if (!Token::Match(this, "++|--"))
|
||||||
return true;
|
return true;
|
||||||
const Token *tokbefore = _previous;
|
const Token *tokbefore = mPrevious;
|
||||||
const Token *tokafter = _next;
|
const Token *tokafter = mNext;
|
||||||
for (int distance = 1; distance < 10 && tokbefore; distance++) {
|
for (int distance = 1; distance < 10 && tokbefore; distance++) {
|
||||||
if (tokbefore == _astOperand1)
|
if (tokbefore == _astOperand1)
|
||||||
return false;
|
return false;
|
||||||
if (tokafter == _astOperand1)
|
if (tokafter == _astOperand1)
|
||||||
return true;
|
return true;
|
||||||
tokbefore = tokbefore->_previous;
|
tokbefore = tokbefore->mPrevious;
|
||||||
tokafter = tokafter->_previous;
|
tokafter = tokafter->mPrevious;
|
||||||
}
|
}
|
||||||
return false; // <- guess
|
return false; // <- guess
|
||||||
}
|
}
|
||||||
|
|
12
lib/token.h
12
lib/token.h
|
@ -530,7 +530,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Token *next() const {
|
Token *next() const {
|
||||||
return _next;
|
return mNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ public:
|
||||||
void insertToken(const std::string &tokenStr, const std::string &originalNameStr=emptyString, bool prepend=false);
|
void insertToken(const std::string &tokenStr, const std::string &originalNameStr=emptyString, bool prepend=false);
|
||||||
|
|
||||||
Token *previous() const {
|
Token *previous() const {
|
||||||
return _previous;
|
return mPrevious;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -880,10 +880,10 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void next(Token *nextToken) {
|
void next(Token *nextToken) {
|
||||||
_next = nextToken;
|
mNext = nextToken;
|
||||||
}
|
}
|
||||||
void previous(Token *previousToken) {
|
void previous(Token *previousToken) {
|
||||||
_previous = previousToken;
|
mPrevious = previousToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** used by deleteThis() to take data from token to delete */
|
/** used by deleteThis() to take data from token to delete */
|
||||||
|
@ -905,8 +905,8 @@ private:
|
||||||
|
|
||||||
std::string _str;
|
std::string _str;
|
||||||
|
|
||||||
Token *_next;
|
Token *mNext;
|
||||||
Token *_previous;
|
Token *mPrevious;
|
||||||
Token *_link;
|
Token *_link;
|
||||||
|
|
||||||
// symbol database information
|
// symbol database information
|
||||||
|
|
Loading…
Reference in New Issue