Use the ExtensionDirectiveHandler type in other places where it makes sense.

Since we already have this type it's a shame to keep dragging a pair of object
and method around explicitly.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172584 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eli Bendersky 2013-01-16 00:50:52 +00:00
parent 68b8d4f4ce
commit 171192f149
5 changed files with 20 additions and 18 deletions

View File

@ -68,6 +68,8 @@ public:
class MCAsmParser {
public:
typedef bool (*DirectiveHandler)(MCAsmParserExtension*, StringRef, SMLoc);
typedef std::pair<MCAsmParserExtension*, DirectiveHandler>
ExtensionDirectiveHandler;
private:
MCAsmParser(const MCAsmParser &) LLVM_DELETED_FUNCTION;
@ -83,9 +85,8 @@ protected: // Can only create subclasses.
public:
virtual ~MCAsmParser();
virtual void AddDirectiveHandler(MCAsmParserExtension *Object,
StringRef Directive,
DirectiveHandler Handler) = 0;
virtual void AddDirectiveHandler(StringRef Directive,
ExtensionDirectiveHandler Handler) = 0;
virtual SourceMgr &getSourceManager() = 0;

View File

@ -122,8 +122,6 @@ private:
/// ExtensionDirectiveMap - maps directive names to handler methods in parser
/// extensions. Extensions register themselves in this map by calling
/// AddDirectiveHandler.
typedef std::pair<MCAsmParserExtension*, DirectiveHandler>
ExtensionDirectiveHandler;
StringMap<ExtensionDirectiveHandler> ExtensionDirectiveMap;
/// MacroMap - Map of currently defined macros.
@ -160,10 +158,9 @@ public:
virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false);
virtual void AddDirectiveHandler(MCAsmParserExtension *Object,
StringRef Directive,
DirectiveHandler Handler) {
ExtensionDirectiveMap[Directive] = std::make_pair(Object, Handler);
virtual void AddDirectiveHandler(StringRef Directive,
ExtensionDirectiveHandler Handler) {
ExtensionDirectiveMap[Directive] = Handler;
}
public:

View File

@ -24,10 +24,11 @@ using namespace llvm;
namespace {
class COFFAsmParser : public MCAsmParserExtension {
template<bool (COFFAsmParser::*Handler)(StringRef, SMLoc)>
template<bool (COFFAsmParser::*HandlerMethod)(StringRef, SMLoc)>
void AddDirectiveHandler(StringRef Directive) {
getParser().AddDirectiveHandler(this, Directive,
HandleDirective<COFFAsmParser, Handler>);
MCAsmParser::ExtensionDirectiveHandler Handler = std::make_pair(
this, HandleDirective<COFFAsmParser, HandlerMethod>);
getParser().AddDirectiveHandler(Directive, Handler);
}
bool ParseSectionSwitch(StringRef Section,

View File

@ -26,10 +26,11 @@ namespace {
/// \brief Implementation of directive handling which is shared across all
/// Darwin targets.
class DarwinAsmParser : public MCAsmParserExtension {
template<bool (DarwinAsmParser::*Handler)(StringRef, SMLoc)>
template<bool (DarwinAsmParser::*HandlerMethod)(StringRef, SMLoc)>
void AddDirectiveHandler(StringRef Directive) {
getParser().AddDirectiveHandler(this, Directive,
HandleDirective<DarwinAsmParser, Handler>);
MCAsmParser::ExtensionDirectiveHandler Handler = std::make_pair(
this, HandleDirective<DarwinAsmParser, HandlerMethod>);
getParser().AddDirectiveHandler(Directive, Handler);
}
bool ParseSectionSwitch(const char *Segment, const char *Section,

View File

@ -22,10 +22,12 @@ using namespace llvm;
namespace {
class ELFAsmParser : public MCAsmParserExtension {
template<bool (ELFAsmParser::*Handler)(StringRef, SMLoc)>
template<bool (ELFAsmParser::*HandlerMethod)(StringRef, SMLoc)>
void AddDirectiveHandler(StringRef Directive) {
getParser().AddDirectiveHandler(this, Directive,
HandleDirective<ELFAsmParser, Handler>);
MCAsmParser::ExtensionDirectiveHandler Handler = std::make_pair(
this, HandleDirective<ELFAsmParser, HandlerMethod>);
getParser().AddDirectiveHandler(Directive, Handler);
}
bool ParseSectionSwitch(StringRef Section, unsigned Type,