mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-20 14:29:27 +00: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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
56a5886b20
commit
894c1af05f
@ -38,12 +38,22 @@ protected: // Can only create subclasses.
|
|||||||
|
|
||||||
/// TheTarget - The Target that this machine was created for.
|
/// TheTarget - The Target that this machine was created for.
|
||||||
const Target &TheTarget;
|
const Target &TheTarget;
|
||||||
|
MCAsmLexer *Lexer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~TargetAsmLexer();
|
virtual ~TargetAsmLexer();
|
||||||
|
|
||||||
const Target &getTarget() const { return TheTarget; }
|
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.
|
/// Lex - Consume the next token from the input stream and return it.
|
||||||
const AsmToken &Lex() {
|
const AsmToken &Lex() {
|
||||||
return CurTok = LexToken();
|
return CurTok = LexToken();
|
||||||
|
@ -10,5 +10,5 @@
|
|||||||
#include "llvm/Target/TargetAsmLexer.h"
|
#include "llvm/Target/TargetAsmLexer.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
TargetAsmLexer::TargetAsmLexer(const Target &T) : TheTarget(T) {}
|
TargetAsmLexer::TargetAsmLexer(const Target &T) : TheTarget(T), Lexer(NULL) {}
|
||||||
TargetAsmLexer::~TargetAsmLexer() {}
|
TargetAsmLexer::~TargetAsmLexer() {}
|
||||||
|
@ -22,13 +22,12 @@ namespace {
|
|||||||
|
|
||||||
class X86AsmLexer : public TargetAsmLexer {
|
class X86AsmLexer : public TargetAsmLexer {
|
||||||
const MCAsmInfo &AsmInfo;
|
const MCAsmInfo &AsmInfo;
|
||||||
MCAsmLexer *Lexer;
|
|
||||||
|
|
||||||
bool tentativeIsValid;
|
bool tentativeIsValid;
|
||||||
AsmToken tentativeToken;
|
AsmToken tentativeToken;
|
||||||
|
|
||||||
const AsmToken &lexTentative() {
|
const AsmToken &lexTentative() {
|
||||||
tentativeToken = Lexer->Lex();
|
tentativeToken = getLexer()->Lex();
|
||||||
tentativeIsValid = true;
|
tentativeIsValid = true;
|
||||||
return tentativeToken;
|
return tentativeToken;
|
||||||
}
|
}
|
||||||
@ -39,7 +38,7 @@ class X86AsmLexer : public TargetAsmLexer {
|
|||||||
return tentativeToken;
|
return tentativeToken;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Lexer->Lex();
|
return getLexer()->Lex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,11 +63,7 @@ protected:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
X86AsmLexer(const Target &T, const MCAsmInfo &MAI)
|
X86AsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||||
: TargetAsmLexer(T), AsmInfo(MAI), Lexer(NULL), tentativeIsValid(false) {
|
: TargetAsmLexer(T), AsmInfo(MAI), tentativeIsValid(false) {
|
||||||
}
|
|
||||||
|
|
||||||
void InstallLexer(MCAsmLexer &L) {
|
|
||||||
Lexer = &L;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user