Commit 5bbb882b authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Introduced expandBuiltinMacro().

parent 3c689f78
......@@ -726,44 +726,33 @@ void Preprocessor::preprocess(const QByteArray &fileName, const QByteArray &sour
const QByteArray spell = tokenSpell(*identifierToken);
if (env->isBuiltinMacro(spell)) {
const Macro trivial;
if (env->isBuiltinMacro(spell))
expandBuiltinMacro(identifierToken, spell);
if (client)
client->startExpandingMacro(identifierToken->offset,
trivial, spell);
else {
if (Macro *m = env->resolve(spell)) {
if (! m->isFunctionLike()) {
if (0 == (m = processObjectLikeMacro(identifierToken, spell, m)))
continue;
expand(spell, _result);
if (client)
client->stopExpandingMacro(_dot->offset, trivial);
continue;
}
if (Macro *m = env->resolve(spell)) {
if (! m->isFunctionLike()) {
if (0 == (m = processObjectLikeMacro(identifierToken, spell, m)))
continue;
// the macro expansion generated something that looks like
// a function-like macro.
}
// `m' is function-like macro.
// the macro expansion generated something that looks like
// a function-like macro.
}
if (_dot->is(T_LPAREN)) {
skipActualArguments();
// `m' is function-like macro.
if (_dot->is(T_LPAREN)) {
skipActualArguments();
if (_dot->is(T_RPAREN)) {
expandFunctionLikeMacro(identifierToken, m);
continue;
if (_dot->is(T_RPAREN)) {
expandFunctionLikeMacro(identifierToken, m);
continue;
}
}
}
}
// it's not a function or object-like macro.
_result->append(spell);
// it's not a function or object-like macro.
_result->append(spell);
}
}
}
}
......@@ -825,6 +814,21 @@ Macro *Preprocessor::processObjectLikeMacro(TokenIterator identifierToken,
return 0;
}
void Preprocessor::expandBuiltinMacro(TokenIterator identifierToken,
const QByteArray &spell)
{
const Macro trivial;
if (client)
client->startExpandingMacro(identifierToken->offset,
trivial, spell);
expand(spell, _result);
if (client)
client->stopExpandingMacro(_dot->offset, trivial);
}
void Preprocessor::expandObjectLikeMacro(TokenIterator identifierToken,
const QByteArray &spell,
Macro *m,
......
......@@ -104,6 +104,8 @@ private:
QByteArray expand(const QByteArray &source);
void expand(const QByteArray &source, QByteArray *result);
void expand(const char *first, const char *last, QByteArray *result);
void expandBuiltinMacro(TokenIterator identifierToken,
const QByteArray &spell);
void expandObjectLikeMacro(TokenIterator identifierToken,
const QByteArray &spell,
Macro *m, QByteArray *result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment