Token::index(): Created Token member that indicates the Token position in the token list. It can be used to quickly check if tok1 precedes tok2.
This commit is contained in:
parent
d636a83f8b
commit
beea7fa8d2
|
@ -224,7 +224,7 @@ bool precedes(const Token * tok1, const Token * tok2)
|
||||||
return false;
|
return false;
|
||||||
if (!tok2)
|
if (!tok2)
|
||||||
return false;
|
return false;
|
||||||
return tok1->progressValue() < tok2->progressValue();
|
return tok1->index() < tok2->index();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isAliased(const Token * startTok, const Token * endTok, unsigned int varid)
|
static bool isAliased(const Token * startTok, const Token * endTok, unsigned int varid)
|
||||||
|
|
|
@ -1742,6 +1742,13 @@ void Token::assignProgressValues(Token *tok)
|
||||||
tok2->mImpl->mProgressValue = count++ * 100 / total_count;
|
tok2->mImpl->mProgressValue = count++ * 100 / total_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Token::assignIndexes()
|
||||||
|
{
|
||||||
|
unsigned int index = (mPrevious ? mPrevious->mImpl->mIndex : 0) + 1;
|
||||||
|
for (Token *tok = this; tok; tok = tok->next())
|
||||||
|
tok->mImpl->mIndex = index++;
|
||||||
|
}
|
||||||
|
|
||||||
void Token::setValueType(ValueType *vt)
|
void Token::setValueType(ValueType *vt)
|
||||||
{
|
{
|
||||||
if (vt != mImpl->mValueType) {
|
if (vt != mImpl->mValueType) {
|
||||||
|
|
14
lib/token.h
14
lib/token.h
|
@ -76,6 +76,11 @@ struct TokenImpl {
|
||||||
*/
|
*/
|
||||||
unsigned int mProgressValue;
|
unsigned int mProgressValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Token index. Position in token list
|
||||||
|
*/
|
||||||
|
unsigned int mIndex;
|
||||||
|
|
||||||
// original name like size_t
|
// original name like size_t
|
||||||
std::string* mOriginalName;
|
std::string* mOriginalName;
|
||||||
|
|
||||||
|
@ -103,6 +108,7 @@ struct TokenImpl {
|
||||||
, mScope(nullptr)
|
, mScope(nullptr)
|
||||||
, mFunction(nullptr) // Initialize whole union
|
, mFunction(nullptr) // Initialize whole union
|
||||||
, mProgressValue(0)
|
, mProgressValue(0)
|
||||||
|
, mIndex(0)
|
||||||
, mOriginalName(nullptr)
|
, mOriginalName(nullptr)
|
||||||
, mValueType(nullptr)
|
, mValueType(nullptr)
|
||||||
, mValues(nullptr)
|
, mValues(nullptr)
|
||||||
|
@ -853,7 +859,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static void move(Token *srcStart, Token *srcEnd, Token *newLocation);
|
static void move(Token *srcStart, Token *srcEnd, Token *newLocation);
|
||||||
|
|
||||||
/** Get progressValue */
|
/** Get progressValue (0 - 100) */
|
||||||
unsigned int progressValue() const {
|
unsigned int progressValue() const {
|
||||||
return mImpl->mProgressValue;
|
return mImpl->mProgressValue;
|
||||||
}
|
}
|
||||||
|
@ -987,6 +993,12 @@ public:
|
||||||
mImpl->mValues->remove_if(pred);
|
mImpl->mValues->remove_if(pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int index() const {
|
||||||
|
return mImpl->mIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void assignIndexes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void next(Token *nextToken) {
|
void next(Token *nextToken) {
|
||||||
|
|
|
@ -4522,7 +4522,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
|
|
||||||
validate();
|
validate();
|
||||||
|
|
||||||
Token::assignProgressValues(list.front());
|
list.front()->assignIndexes();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue