1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Moved InstallLexer() from the X86-specific AsmLexer

to the TargetAsmLexer class so that clients can
actually use the TargetAsmLexer they get from a
Target.

llvm-svn: 94940
This commit is contained in:
Sean Callanan 2010-01-31 02:28:18 +00:00
parent c2f3c20680
commit 5458663492
3 changed files with 14 additions and 9 deletions

View File

@ -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();

View File

@ -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() {}

View File

@ -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) {
}
};