Improve creation of link() for Token class. Tokenizer::simplifyTokenList() should now return
code where Token::link() actually works.
This commit is contained in:
parent
6eadbaae04
commit
c385b3e045
|
@ -725,11 +725,16 @@ void Tokenizer::simplifyNamespaces()
|
|||
}
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyTokenList()
|
||||
bool Tokenizer::createLinks()
|
||||
{
|
||||
std::list<Token*> links;
|
||||
for (Token *token = _tokens; token; token = token->next())
|
||||
{
|
||||
if (token->link())
|
||||
{
|
||||
token->link(0);
|
||||
}
|
||||
|
||||
if (token->str() == "{")
|
||||
{
|
||||
links.push_back(token);
|
||||
|
@ -739,7 +744,7 @@ void Tokenizer::simplifyTokenList()
|
|||
if (links.size() == 0)
|
||||
{
|
||||
// Error, { and } don't match.
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
token->link(links.back());
|
||||
|
@ -751,8 +756,15 @@ void Tokenizer::simplifyTokenList()
|
|||
if (links.size() > 0)
|
||||
{
|
||||
// Error, { and } don't match.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyTokenList()
|
||||
{
|
||||
createLinks();
|
||||
|
||||
simplifyNamespaces();
|
||||
|
||||
|
@ -1240,6 +1252,8 @@ void Tokenizer::simplifyTokenList()
|
|||
modified |= simplifyRedundantParanthesis();
|
||||
modified |= simplifyCalculations();
|
||||
}
|
||||
|
||||
createLinks();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -176,6 +176,14 @@ private:
|
|||
|
||||
void InsertTokens(Token *dest, Token *src, unsigned int n);
|
||||
|
||||
/**
|
||||
* Setup links for tokens so that one can call Token::link().
|
||||
*
|
||||
* @return false if there was a mismatch with tokens, this
|
||||
* should mean that source code was not valid.
|
||||
*/
|
||||
bool createLinks();
|
||||
|
||||
Token *_tokensBack;
|
||||
std::map<std::string, unsigned int> _typeSize;
|
||||
std::vector<std::string> _files;
|
||||
|
|
Loading…
Reference in New Issue