Refactoring: TOKEN::varId was moved from public to private

This commit is contained in:
Reijo Tomperi 2008-12-08 17:45:55 +00:00
parent 3619552e38
commit 25847fdec4
4 changed files with 21 additions and 8 deletions

View File

@ -284,15 +284,15 @@ private:
for ( const TOKEN *tok = tokenizer.tokens(); tok; tok = tok->next )
{
if ( tok->str() != "i" )
ASSERT_EQUALS( 0, tok->varId );
ASSERT_EQUALS( 0, tok->varId() );
else if ( TOKEN::Match(tok, "i = 1") )
ASSERT_EQUALS( 1, tok->varId );
ASSERT_EQUALS( 1, tok->varId() );
else if ( TOKEN::Match(tok, "i = 2") )
ASSERT_EQUALS( 2, tok->varId );
ASSERT_EQUALS( 2, tok->varId() );
else if ( TOKEN::Match(tok, "i = 3") )
ASSERT_EQUALS( 3, tok->varId );
ASSERT_EQUALS( 3, tok->varId() );
else if ( TOKEN::Match(tok, "i = 4") )
ASSERT_EQUALS( 2, tok->varId );
ASSERT_EQUALS( 2, tok->varId() );
}
}
};

View File

@ -307,3 +307,13 @@ const TOKEN *TOKEN::findtoken(const TOKEN *tok1, const char *tokenstr[])
}
return NULL;
}
unsigned int TOKEN::varId() const
{
return _varId;
}
void TOKEN::varId( unsigned int id )
{
_varId = id;
}

View File

@ -114,15 +114,18 @@ public:
unsigned int FileIndex;
unsigned int linenr;
unsigned int varId;
TOKEN *next;
unsigned int varId() const;
void varId( unsigned int id );
private:
std::string _str;
char * _cstr;
bool _isName;
bool _isNumber;
unsigned int _varId;
};
#endif // TOKEN_H

View File

@ -624,7 +624,7 @@ void Tokenizer::setVarId()
{
// Clear all variable ids
for ( TOKEN *tok = _tokens; tok; tok = tok->next )
tok->varId = 0;
tok->varId( 0 );
// Set variable ids..
unsigned int _varId = 0;
@ -654,7 +654,7 @@ void Tokenizer::setVarId()
for ( tok2 = tok->next; tok2 && indentlevel >= 0; tok2 = tok2->next )
{
if ( tok2->str() == varname )
tok2->varId = _varId;
tok2->varId( _varId );
else if ( tok2->str() == "{" )
++indentlevel;
else if ( tok2->str() == "}" )