forked from qt-creator/qt-creator
		
	[C++] Rewrite of the preprocessor.
This rewrite fixes a couple of issues with the pre-processor. It now supports: - macros in macro bodies - stringification of parameters [cpp.stringize] - the concatenation operator [cpp.concat] - #include MACRO_HERE - defined() inside macro bodies used in pp-conditions. Change-Id: Ifdb78041fb6afadf44f939a4bd66ce2832b8601f Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
This commit is contained in:
		@@ -150,7 +150,7 @@ void Environment::reset()
 | 
			
		||||
    _hash_count = 401;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool Environment::isBuiltinMacro(const QByteArray &s)
 | 
			
		||||
bool Environment::isBuiltinMacro(const Internal::ByteArrayRef &s)
 | 
			
		||||
{
 | 
			
		||||
    if (s.length() != 8)
 | 
			
		||||
        return false;
 | 
			
		||||
@@ -236,6 +236,22 @@ Macro *Environment::resolve(const QByteArray &name) const
 | 
			
		||||
    return it;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Macro *Environment::resolve(const Internal::ByteArrayRef &name) const
 | 
			
		||||
{
 | 
			
		||||
    if (! _macros)
 | 
			
		||||
        return 0;
 | 
			
		||||
 | 
			
		||||
    Macro *it = _hash[hashCode(name) % _hash_count];
 | 
			
		||||
    for (; it; it = it->_next) {
 | 
			
		||||
        if (it->name() != name)
 | 
			
		||||
            continue;
 | 
			
		||||
        else if (it->isHidden())
 | 
			
		||||
            return 0;
 | 
			
		||||
        else break;
 | 
			
		||||
    }
 | 
			
		||||
    return it;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned Environment::hashCode(const QByteArray &s)
 | 
			
		||||
{
 | 
			
		||||
    unsigned hash_value = 0;
 | 
			
		||||
@@ -246,6 +262,16 @@ unsigned Environment::hashCode(const QByteArray &s)
 | 
			
		||||
    return hash_value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned Environment::hashCode(const Internal::ByteArrayRef &s)
 | 
			
		||||
{
 | 
			
		||||
    unsigned hash_value = 0;
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < s.length(); ++i)
 | 
			
		||||
        hash_value = (hash_value << 5) - hash_value + s.at(i);
 | 
			
		||||
 | 
			
		||||
    return hash_value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Environment::rehash()
 | 
			
		||||
{
 | 
			
		||||
    if (_hash) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user