Moved InstallLexer() from the X86-specific AsmLexer
authorSean Callanan <scallanan@apple.com>
Sun, 31 Jan 2010 02:28:18 +0000 (02:28 +0000)
committerSean Callanan <scallanan@apple.com>
Sun, 31 Jan 2010 02:28:18 +0000 (02:28 +0000)
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

include/llvm/Target/TargetAsmLexer.h
lib/Target/TargetAsmLexer.cpp
lib/Target/X86/AsmParser/X86AsmLexer.cpp

index daba1ba88b99bcb06df87585ea662b323ea4d2eb..9fcf449a86cdd6f0499179d0750621fea7697c1a 100644 (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();
index 0ae6c14b6bd19d7c85916747e6b1348a70e86a6f..d4893ff2521ebc13c782f3506078438f26aa1364 100644 (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() {}
index 3998b08588395ac793a18a3ab8e2b2641d1ffe10..71972176c0286879c6d5c2f0458a55ad0a342d28 100644 (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) {
   }
 };