diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2010-07-12 17:54:38 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2010-07-12 17:54:38 +0000 |
| commit | 30a1eaf284118e376327ebd04e4de1a558fa33c1 (patch) | |
| tree | cf8c51777fa669b4e2b4c300b4f5ebc6e4239097 /include/llvm/MC | |
| parent | 312c106f496e9a3f88a6bdbaca750d23b0432df1 (diff) | |
| download | external_llvm-30a1eaf284118e376327ebd04e4de1a558fa33c1.zip external_llvm-30a1eaf284118e376327ebd04e4de1a558fa33c1.tar.gz external_llvm-30a1eaf284118e376327ebd04e4de1a558fa33c1.tar.bz2 | |
MCAsmParser: Pull some directive handling out into a helper class, and change
DirectiveMap to be based on MCAsmParserExtension.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108161 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/MC')
| -rw-r--r-- | include/llvm/MC/MCParser/AsmParser.h | 18 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/MCAsmParser.h | 12 |
2 files changed, 20 insertions, 10 deletions
diff --git a/include/llvm/MC/MCParser/AsmParser.h b/include/llvm/MC/MCParser/AsmParser.h index 0ad7941..bbf2ebf 100644 --- a/include/llvm/MC/MCParser/AsmParser.h +++ b/include/llvm/MC/MCParser/AsmParser.h @@ -26,6 +26,7 @@ namespace llvm { class AsmCond; class AsmToken; +class MCAsmParserExtension; class MCContext; class MCExpr; class MCInst; @@ -43,6 +44,7 @@ private: MCContext &Ctx; MCStreamer &Out; SourceMgr &SrcMgr; + MCAsmParserExtension *GenericParser; TargetAsmParser *TargetParser; /// This is the current buffer index we're lexing from as managed by the @@ -56,18 +58,20 @@ private: /// invoked after the directive identifier is read and is responsible for /// parsing and validating the rest of the directive. The handler is passed /// in the directive name and the location of the directive keyword. - StringMap<bool(AsmParser::*)(StringRef, SMLoc)> DirectiveMap; + StringMap<std::pair<MCAsmParserExtension*, DirectiveHandler> > DirectiveMap; public: AsmParser(const Target &T, SourceMgr &SM, MCContext &Ctx, MCStreamer &Out, const MCAsmInfo &MAI); ~AsmParser(); bool Run(bool NoInitialTextSection, bool NoFinalize = false); - - void AddDirectiveHandler(StringRef Directive, - bool (AsmParser::*Handler)(StringRef, SMLoc)) { - DirectiveMap[Directive] = Handler; + + void AddDirectiveHandler(MCAsmParserExtension *Object, + StringRef Directive, + DirectiveHandler Handler) { + DirectiveMap[Directive] = std::make_pair(Object, Handler); } + public: TargetAsmParser &getTargetParser() const { return *TargetParser; } void setTargetParser(TargetAsmParser &P); @@ -155,10 +159,6 @@ private: bool ParseDirectiveElse(SMLoc DirectiveLoc); // ".else" bool ParseDirectiveEndIf(SMLoc DirectiveLoc); // .endif - bool ParseDirectiveFile(StringRef, SMLoc DirectiveLoc); // ".file" - bool ParseDirectiveLine(StringRef, SMLoc DirectiveLoc); // ".line" - bool ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc); // ".loc" - /// ParseEscapedString - Parse the current token as a string which may include /// escaped characters and return the string contents. bool ParseEscapedString(std::string &Data); diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h index 176c3a3..d78f512 100644 --- a/include/llvm/MC/MCParser/MCAsmParser.h +++ b/include/llvm/MC/MCParser/MCAsmParser.h @@ -15,15 +15,21 @@ namespace llvm { class AsmToken; class MCAsmLexer; +class MCAsmParserExtension; class MCContext; class MCExpr; class MCStreamer; class SMLoc; +class StringRef; class Twine; /// MCAsmParser - Generic assembler parser interface, for use by target specific /// assembly parsers. class MCAsmParser { +public: + typedef bool (MCAsmParserExtension::*DirectiveHandler)(StringRef, SMLoc); + +private: MCAsmParser(const MCAsmParser &); // DO NOT IMPLEMENT void operator=(const MCAsmParser &); // DO NOT IMPLEMENT protected: // Can only create subclasses. @@ -32,11 +38,15 @@ protected: // Can only create subclasses. public: virtual ~MCAsmParser(); + virtual void AddDirectiveHandler(MCAsmParserExtension *Object, + StringRef Directive, + DirectiveHandler Handler) = 0; + virtual MCAsmLexer &getLexer() = 0; virtual MCContext &getContext() = 0; - /// getSteamer - Return the output streamer for the assembler. + /// getStreamer - Return the output streamer for the assembler. virtual MCStreamer &getStreamer() = 0; /// Warning - Emit a warning at the location \arg L, with the message \arg |
