Tokenizer: Refactoring simplifyPlatformTypes()
This commit is contained in:
parent
5e78dae143
commit
908e1b991e
101
lib/tokenize.cpp
101
lib/tokenize.cpp
|
@ -5579,17 +5579,14 @@ void Tokenizer::simplifyPlatformTypes()
|
||||||
enum { isLongLong, isLong, isInt } type;
|
enum { isLongLong, isLong, isInt } type;
|
||||||
|
|
||||||
/** @todo This assumes a flat address space. Not true for segmented address space (FAR *). */
|
/** @todo This assumes a flat address space. Not true for segmented address space (FAR *). */
|
||||||
if (_settings->sizeof_size_t == 8) {
|
|
||||||
if (_settings->sizeof_long == 8)
|
if (_settings->sizeof_size_t == _settings->sizeof_long)
|
||||||
type = isLong;
|
type = isLong;
|
||||||
else
|
else if (_settings->sizeof_size_t == _settings->sizeof_long_long)
|
||||||
type = isLongLong;
|
type = isLongLong;
|
||||||
} else if (_settings->sizeof_size_t == 4) {
|
else if (_settings->sizeof_size_t == _settings->sizeof_int)
|
||||||
if (_settings->sizeof_long == 4)
|
type = isInt;
|
||||||
type = isLong;
|
else
|
||||||
else
|
|
||||||
type = isInt;
|
|
||||||
} else
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
|
@ -5636,52 +5633,50 @@ void Tokenizer::simplifyPlatformTypes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings->isWindowsPlatform()) {
|
const std::string platform_type(_settings->platformString());
|
||||||
std::string platform_type(_settings->platformString());
|
|
||||||
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (tok->tokType() != Token::eType && tok->tokType() != Token::eName)
|
if (tok->tokType() != Token::eType && tok->tokType() != Token::eName)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const Library::PlatformType * const platformtype = _settings->library.platform_type(tok->str(), platform_type);
|
const Library::PlatformType * const platformtype = _settings->library.platform_type(tok->str(), platform_type);
|
||||||
|
|
||||||
if (platformtype) {
|
if (platformtype) {
|
||||||
// check for namespace
|
// check for namespace
|
||||||
if (tok->strAt(-1) == "::") {
|
if (tok->strAt(-1) == "::") {
|
||||||
const Token * tok1 = tok->tokAt(-2);
|
const Token * tok1 = tok->tokAt(-2);
|
||||||
// skip when non-global namespace defined
|
// skip when non-global namespace defined
|
||||||
if (tok1 && tok1->tokType() == Token::eName)
|
if (tok1 && tok1->tokType() == Token::eName)
|
||||||
continue;
|
continue;
|
||||||
tok = tok->tokAt(-1);
|
tok = tok->tokAt(-1);
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
}
|
|
||||||
Token *typeToken;
|
|
||||||
if (platformtype->_const_ptr) {
|
|
||||||
tok->str("const");
|
|
||||||
tok->insertToken("*");
|
|
||||||
tok->insertToken(platformtype->_type);
|
|
||||||
typeToken = tok;
|
|
||||||
} else if (platformtype->_pointer) {
|
|
||||||
tok->str(platformtype->_type);
|
|
||||||
typeToken = tok;
|
|
||||||
tok->insertToken("*");
|
|
||||||
} else if (platformtype->_ptr_ptr) {
|
|
||||||
tok->str(platformtype->_type);
|
|
||||||
typeToken = tok;
|
|
||||||
tok->insertToken("*");
|
|
||||||
tok->insertToken("*");
|
|
||||||
} else {
|
|
||||||
tok->originalName(tok->str());
|
|
||||||
tok->str(platformtype->_type);
|
|
||||||
typeToken = tok;
|
|
||||||
}
|
|
||||||
if (platformtype->_signed)
|
|
||||||
typeToken->isSigned(true);
|
|
||||||
if (platformtype->_unsigned)
|
|
||||||
typeToken->isUnsigned(true);
|
|
||||||
if (platformtype->_long)
|
|
||||||
typeToken->isLong(true);
|
|
||||||
}
|
}
|
||||||
|
Token *typeToken;
|
||||||
|
if (platformtype->_const_ptr) {
|
||||||
|
tok->str("const");
|
||||||
|
tok->insertToken("*");
|
||||||
|
tok->insertToken(platformtype->_type);
|
||||||
|
typeToken = tok;
|
||||||
|
} else if (platformtype->_pointer) {
|
||||||
|
tok->str(platformtype->_type);
|
||||||
|
typeToken = tok;
|
||||||
|
tok->insertToken("*");
|
||||||
|
} else if (platformtype->_ptr_ptr) {
|
||||||
|
tok->str(platformtype->_type);
|
||||||
|
typeToken = tok;
|
||||||
|
tok->insertToken("*");
|
||||||
|
tok->insertToken("*");
|
||||||
|
} else {
|
||||||
|
tok->originalName(tok->str());
|
||||||
|
tok->str(platformtype->_type);
|
||||||
|
typeToken = tok;
|
||||||
|
}
|
||||||
|
if (platformtype->_signed)
|
||||||
|
typeToken->isSigned(true);
|
||||||
|
if (platformtype->_unsigned)
|
||||||
|
typeToken->isUnsigned(true);
|
||||||
|
if (platformtype->_long)
|
||||||
|
typeToken->isLong(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue