Commit e50d60ac authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Introduced MacroResolver.

parent 913b1bf0
......@@ -432,6 +432,7 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
Document::Ptr previousDoc = snapshot.value(fileName);
if (previousDoc) {
Control *control = previousDoc->control();
previousDoc->control();
Identifier *id = control->findIdentifier(symbolId->chars(), symbolId->size());
if (! id)
continue; // skip this document, it's not using symbolId.
......
......@@ -83,6 +83,7 @@ class Semantic;
class Control;
class MemoryPool;
class DiagnosticClient;
class MacroResolver;
class Identifier;
class Literal;
......
......@@ -59,6 +59,12 @@
CPLUSPLUS_BEGIN_NAMESPACE
MacroResolver::MacroResolver()
{ }
MacroResolver::~MacroResolver()
{ }
template <typename _Iterator>
static void delete_map_entries(_Iterator first, _Iterator last)
{
......@@ -87,7 +93,8 @@ public:
Data(Control *control)
: control(control),
translationUnit(0),
diagnosticClient(0)
diagnosticClient(0),
macroResolver(0)
{ }
~Data()
......@@ -516,6 +523,7 @@ public:
Control *control;
TranslationUnit *translationUnit;
DiagnosticClient *diagnosticClient;
MacroResolver *macroResolver;
LiteralTable<Identifier> identifiers;
LiteralTable<StringLiteral> stringLiterals;
LiteralTable<NumericLiteral> numericLiterals;
......@@ -576,6 +584,12 @@ TranslationUnit *Control::switchTranslationUnit(TranslationUnit *unit)
return previousTranslationUnit;
}
MacroResolver *Control::macroResolver() const
{ return d->macroResolver; }
void Control::setMacroResolver(MacroResolver *macroResolver)
{ d->macroResolver = macroResolver; }
DiagnosticClient *Control::diagnosticClient() const
{ return d->diagnosticClient; }
......
......@@ -55,6 +55,18 @@
CPLUSPLUS_BEGIN_HEADER
CPLUSPLUS_BEGIN_NAMESPACE
class CPLUSPLUS_EXPORT MacroResolver
{
MacroResolver(const MacroResolver &other);
void operator = (const MacroResolver &other);
public:
MacroResolver();
virtual ~MacroResolver();
virtual bool isMacro(TranslationUnit *unit, unsigned tokenIndex) const = 0;
};
class CPLUSPLUS_EXPORT Control
{
public:
......@@ -64,6 +76,9 @@ public:
TranslationUnit *translationUnit() const;
TranslationUnit *switchTranslationUnit(TranslationUnit *unit);
MacroResolver *macroResolver() const;
void setMacroResolver(MacroResolver *macroResolver);
DiagnosticClient *diagnosticClient() const;
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
......
......@@ -244,6 +244,14 @@ void Parser::match(int kind, unsigned *token)
}
}
bool Parser::isMacro(unsigned tokenIndex) const
{
if (MacroResolver *r = _control->macroResolver())
return r->isMacro(_translationUnit, tokenIndex);
return false;
}
bool Parser::parseClassOrNamespaceName(NameAST *&node)
{
if (LA() == T_IDENTIFIER) {
......
......@@ -286,6 +286,8 @@ private:
inline void rewind(unsigned cursor)
{ _tokenIndex = cursor; }
bool isMacro(unsigned tokenIndex) const;
private:
TranslationUnit *_translationUnit;
Control *_control;
......
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