diff options
author | Sean Callanan <scallanan@apple.com> | 2010-01-31 02:28:18 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2010-01-31 02:28:18 +0000 |
commit | 894c1af05fb3f0d8e2ee6565816fa220b260ed9d (patch) | |
tree | b29f6da62e1635f66cf192ea4bd75ce6de35b971 | |
parent | 56a5886b20433569e5eb9c5b1ad350ef0c0e0596 (diff) |
Moved InstallLexer() from the X86-specific AsmLexer
to the TargetAsmLexer class so that clients can
actually use the TargetAsmLexer they get from a
Target.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94940 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Target/TargetAsmLexer.h | 10 | ||||
-rw-r--r-- | lib/Target/TargetAsmLexer.cpp | 2 | ||||
-rw-r--r-- | lib/Target/X86/AsmParser/X86AsmLexer.cpp | 11 |
3 files changed, 14 insertions, 9 deletions
diff --git a/include/llvm/Target/TargetAsmLexer.h b/include/llvm/Target/TargetAsmLexer.h index daba1ba88b..9fcf449a86 100644 --- a/include/llvm/Target/TargetAsmLexer.h +++ b/include/llvm/Target/TargetAsmLexer.h @@ -38,12 +38,22 @@ protected: // Can only create subclasses. /// TheTarget - The Target that this machine was created for. const Target &TheTarget; + MCAsmLexer *Lexer; public: virtual ~TargetAsmLexer(); const Target &getTarget() const { return TheTarget; } + /// InstallLexer - Set the lexer to get tokens from lower-level lexer \arg L. + void InstallLexer(MCAsmLexer &L) { + Lexer = &L; + } + + MCAsmLexer *getLexer() { + return Lexer; + } + /// Lex - Consume the next token from the input stream and return it. const AsmToken &Lex() { return CurTok = LexToken(); diff --git a/lib/Target/TargetAsmLexer.cpp b/lib/Target/TargetAsmLexer.cpp index 0ae6c14b6b..d4893ff252 100644 --- a/lib/Target/TargetAsmLexer.cpp +++ b/lib/Target/TargetAsmLexer.cpp @@ -10,5 +10,5 @@ #include "llvm/Target/TargetAsmLexer.h" using namespace llvm; -TargetAsmLexer::TargetAsmLexer(const Target &T) : TheTarget(T) {} +TargetAsmLexer::TargetAsmLexer(const Target &T) : TheTarget(T), Lexer(NULL) {} TargetAsmLexer::~TargetAsmLexer() {} diff --git a/lib/Target/X86/AsmParser/X86AsmLexer.cpp b/lib/Target/X86/AsmParser/X86AsmLexer.cpp index 3998b08588..71972176c0 100644 --- a/lib/Target/X86/AsmParser/X86AsmLexer.cpp +++ b/lib/Target/X86/AsmParser/X86AsmLexer.cpp @@ -22,13 +22,12 @@ namespace { class X86AsmLexer : public TargetAsmLexer { const MCAsmInfo &AsmInfo; - MCAsmLexer *Lexer; bool tentativeIsValid; AsmToken tentativeToken; const AsmToken &lexTentative() { - tentativeToken = Lexer->Lex(); + tentativeToken = getLexer()->Lex(); tentativeIsValid = true; return tentativeToken; } @@ -39,7 +38,7 @@ class X86AsmLexer : public TargetAsmLexer { return tentativeToken; } else { - return Lexer->Lex(); + return getLexer()->Lex(); } } @@ -64,11 +63,7 @@ protected: } public: X86AsmLexer(const Target &T, const MCAsmInfo &MAI) - : TargetAsmLexer(T), AsmInfo(MAI), Lexer(NULL), tentativeIsValid(false) { - } - - void InstallLexer(MCAsmLexer &L) { - Lexer = &L; + : TargetAsmLexer(T), AsmInfo(MAI), tentativeIsValid(false) { } }; |