Commit 3e9d4358 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Pass the translation units to the matcher.

parent 5644775d
......@@ -34,65 +34,23 @@
using namespace CPlusPlus;
ASTMatcher::ASTMatcher(Control *control)
: _control(control)
ASTMatcher::ASTMatcher(TranslationUnit *translationUnit, TranslationUnit *patternTranslationUnit)
: _translationUnit(translationUnit), _patternTranslationUnit(patternTranslationUnit)
{ }
{ }
Control *ASTMatcher::control() const
{ return _control; }
TranslationUnit *ASTMatcher::translationUnit() const
{ return _control->translationUnit(); }
unsigned ASTMatcher::tokenCount() const
{ return translationUnit()->tokenCount(); }
const Token &ASTMatcher::tokenAt(unsigned index) const
{ return translationUnit()->tokenAt(index); }
int ASTMatcher::tokenKind(unsigned index) const
{ return translationUnit()->tokenKind(index); }
const char *ASTMatcher::spell(unsigned index) const
{ return translationUnit()->spell(index); }
Identifier *ASTMatcher::identifier(unsigned index) const
{ return translationUnit()->identifier(index); }
Literal *ASTMatcher::literal(unsigned index) const
{ return translationUnit()->literal(index); }
NumericLiteral *ASTMatcher::numericLiteral(unsigned index) const
{ return translationUnit()->numericLiteral(index); }
StringLiteral *ASTMatcher::stringLiteral(unsigned index) const
{ return translationUnit()->stringLiteral(index); }
void ASTMatcher::getPosition(unsigned offset,
unsigned *line,
unsigned *column,
StringLiteral **fileName) const
{ translationUnit()->getPosition(offset, line, column, fileName); }
void ASTMatcher::getTokenPosition(unsigned index,
unsigned *line,
unsigned *column,
StringLiteral **fileName) const
{ translationUnit()->getTokenPosition(index, line, column, fileName); }
void ASTMatcher::getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const
{ getPosition(tokenAt(index).begin(), line, column); }
{ return _translationUnit; }
void ASTMatcher::getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const
{ getPosition(tokenAt(index).end(), line, column); }
TranslationUnit *ASTMatcher::patternTranslationUnit() const
{ return _patternTranslationUnit; }
bool ASTMatcher::matchToken(unsigned index, unsigned otherIndex) const
bool ASTMatcher::matchToken(unsigned tokenIndex, unsigned patternTokenIndex) const
const Token &token = tokenAt(index);
const Token &otherToken = tokenAt(otherIndex);
const Token &token = _translationUnit->tokenAt(tokenIndex);
const Token &otherToken = _patternTranslationUnit->tokenAt(patternTokenIndex);
if (token.f.kind != otherToken.f.kind)
return false;
else if ( {
......@@ -36,34 +36,11 @@ namespace CPlusPlus {
ASTMatcher(Control *control);
ASTMatcher(TranslationUnit *translationUnit, TranslationUnit *patternTranslationUnit);
virtual ~ASTMatcher();
Control *control() const;
TranslationUnit *translationUnit() const;
unsigned tokenCount() const;
const Token &tokenAt(unsigned index) const;
int tokenKind(unsigned index) const;
const char *spell(unsigned index) const;
Identifier *identifier(unsigned index) const;
Literal *literal(unsigned index) const;
NumericLiteral *numericLiteral(unsigned index) const;
StringLiteral *stringLiteral(unsigned index) const;
void getPosition(unsigned offset,
unsigned *line,
unsigned *column = 0,
StringLiteral **fileName = 0) const;
void getTokenPosition(unsigned index,
unsigned *line,
unsigned *column = 0,
StringLiteral **fileName = 0) const;
void getTokenStartPosition(unsigned index, unsigned *line, unsigned *column) const;
void getTokenEndPosition(unsigned index, unsigned *line, unsigned *column) const;
TranslationUnit *patternTranslationUnit() const;
bool matchToken(unsigned index, unsigned otherIndex) const;
......@@ -191,7 +168,8 @@ public:
virtual bool match(ObjCSynchronizedStatementAST *node, ObjCSynchronizedStatementAST *pattern);
Control *_control;
TranslationUnit *_translationUnit;
TranslationUnit *_patternTranslationUnit;
} // end of namespace CPlusPlus
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