forked from OSchip/llvm-project
Now that GenericAsmParser was folded into AsmParser, some methods and types can
return into the safe harbor of AsmParser's private areas. llvm-svn: 172637
This commit is contained in:
parent
bcd80b4723
commit
a313ae6cf9
|
@ -44,25 +44,6 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/// \brief Helper types for tracking macro definitions.
|
||||
typedef std::vector<AsmToken> MCAsmMacroArgument;
|
||||
typedef std::vector<MCAsmMacroArgument> MCAsmMacroArguments;
|
||||
typedef std::pair<StringRef, MCAsmMacroArgument> MCAsmMacroParameter;
|
||||
typedef std::vector<MCAsmMacroParameter> MCAsmMacroParameters;
|
||||
|
||||
struct MCAsmMacro {
|
||||
StringRef Name;
|
||||
StringRef Body;
|
||||
MCAsmMacroParameters Parameters;
|
||||
|
||||
public:
|
||||
MCAsmMacro(StringRef N, StringRef B, const MCAsmMacroParameters &P) :
|
||||
Name(N), Body(B), Parameters(P) {}
|
||||
|
||||
MCAsmMacro(const MCAsmMacro& Other)
|
||||
: Name(Other.Name), Body(Other.Body), Parameters(Other.Parameters) {}
|
||||
};
|
||||
|
||||
/// MCAsmParser - Generic assembler parser interface, for use by target specific
|
||||
/// assembly parsers.
|
||||
class MCAsmParser {
|
||||
|
@ -159,41 +140,6 @@ public:
|
|||
/// recovery.
|
||||
virtual void EatToEndOfStatement() = 0;
|
||||
|
||||
/// \brief Are macros enabled in the parser?
|
||||
virtual bool MacrosEnabled() = 0;
|
||||
|
||||
/// \brief Control a flag in the parser that enables or disables macros.
|
||||
virtual void SetMacrosEnabled(bool flag) = 0;
|
||||
|
||||
/// \brief Lookup a previously defined macro.
|
||||
/// \param Name Macro name.
|
||||
/// \returns Pointer to macro. NULL if no such macro was defined.
|
||||
virtual const MCAsmMacro* LookupMacro(StringRef Name) = 0;
|
||||
|
||||
/// \brief Define a new macro with the given name and information.
|
||||
virtual void DefineMacro(StringRef Name, const MCAsmMacro& Macro) = 0;
|
||||
|
||||
/// \brief Undefine a macro. If no such macro was defined, it's a no-op.
|
||||
virtual void UndefineMacro(StringRef Name) = 0;
|
||||
|
||||
/// \brief Are we inside a macro instantiation?
|
||||
virtual bool InsideMacroInstantiation() = 0;
|
||||
|
||||
/// \brief Handle entry to macro instantiation.
|
||||
///
|
||||
/// \param M The macro.
|
||||
/// \param NameLoc Instantiation location.
|
||||
virtual bool HandleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc) = 0;
|
||||
|
||||
/// \brief Handle exit from macro instantiation.
|
||||
virtual void HandleMacroExit() = 0;
|
||||
|
||||
/// ParseMacroArgument - Extract AsmTokens for a macro argument. If the
|
||||
/// argument delimiter is initially unknown, set it to AsmToken::Eof. It will
|
||||
/// be set to the correct delimiter by the method.
|
||||
virtual bool ParseMacroArgument(MCAsmMacroArgument &MA,
|
||||
AsmToken::TokenKind &ArgumentDelimiter) = 0;
|
||||
|
||||
/// ParseExpression - Parse an arbitrary expression.
|
||||
///
|
||||
/// @param Res - The value of the expression. The result is undefined
|
||||
|
|
|
@ -50,6 +50,25 @@ MCAsmParserSemaCallback::~MCAsmParserSemaCallback() {}
|
|||
|
||||
namespace {
|
||||
|
||||
/// \brief Helper types for tracking macro definitions.
|
||||
typedef std::vector<AsmToken> MCAsmMacroArgument;
|
||||
typedef std::vector<MCAsmMacroArgument> MCAsmMacroArguments;
|
||||
typedef std::pair<StringRef, MCAsmMacroArgument> MCAsmMacroParameter;
|
||||
typedef std::vector<MCAsmMacroParameter> MCAsmMacroParameters;
|
||||
|
||||
struct MCAsmMacro {
|
||||
StringRef Name;
|
||||
StringRef Body;
|
||||
MCAsmMacroParameters Parameters;
|
||||
|
||||
public:
|
||||
MCAsmMacro(StringRef N, StringRef B, const MCAsmMacroParameters &P) :
|
||||
Name(N), Body(B), Parameters(P) {}
|
||||
|
||||
MCAsmMacro(const MCAsmMacro& Other)
|
||||
: Name(Other.Name), Body(Other.Body), Parameters(Other.Parameters) {}
|
||||
};
|
||||
|
||||
/// \brief Helper class for storing information about an active macro
|
||||
/// instantiation.
|
||||
struct MacroInstantiation {
|
||||
|
@ -73,7 +92,6 @@ public:
|
|||
MemoryBuffer *I);
|
||||
};
|
||||
|
||||
//struct AsmRewrite;
|
||||
struct ParseStatementInfo {
|
||||
/// ParsedOperands - The parsed operands from the last parsed statement.
|
||||
SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
|
||||
|
@ -205,25 +223,11 @@ public:
|
|||
virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc);
|
||||
virtual bool ParseAbsoluteExpression(int64_t &Res);
|
||||
|
||||
bool ParseMacroArgument(MCAsmMacroArgument &MA,
|
||||
AsmToken::TokenKind &ArgumentDelimiter);
|
||||
|
||||
/// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
|
||||
/// and set \p Res to the identifier contents.
|
||||
virtual bool ParseIdentifier(StringRef &Res);
|
||||
virtual void EatToEndOfStatement();
|
||||
|
||||
virtual bool MacrosEnabled() {return MacrosEnabledFlag;}
|
||||
virtual void SetMacrosEnabled(bool flag) {MacrosEnabledFlag = flag;}
|
||||
|
||||
virtual const MCAsmMacro* LookupMacro(StringRef Name);
|
||||
virtual void DefineMacro(StringRef Name, const MCAsmMacro& Macro);
|
||||
virtual void UndefineMacro(StringRef Name);
|
||||
|
||||
virtual bool InsideMacroInstantiation() {return !ActiveMacros.empty();}
|
||||
virtual bool HandleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc);
|
||||
void HandleMacroExit();
|
||||
|
||||
virtual void CheckForValidSection();
|
||||
/// }
|
||||
|
||||
|
@ -238,6 +242,44 @@ private:
|
|||
const MCAsmMacroArguments &A,
|
||||
const SMLoc &L);
|
||||
|
||||
/// \brief Are macros enabled in the parser?
|
||||
bool MacrosEnabled() {return MacrosEnabledFlag;}
|
||||
|
||||
/// \brief Control a flag in the parser that enables or disables macros.
|
||||
void SetMacrosEnabled(bool Flag) {MacrosEnabledFlag = Flag;}
|
||||
|
||||
/// \brief Lookup a previously defined macro.
|
||||
/// \param Name Macro name.
|
||||
/// \returns Pointer to macro. NULL if no such macro was defined.
|
||||
const MCAsmMacro* LookupMacro(StringRef Name);
|
||||
|
||||
/// \brief Define a new macro with the given name and information.
|
||||
void DefineMacro(StringRef Name, const MCAsmMacro& Macro);
|
||||
|
||||
/// \brief Undefine a macro. If no such macro was defined, it's a no-op.
|
||||
void UndefineMacro(StringRef Name);
|
||||
|
||||
/// \brief Are we inside a macro instantiation?
|
||||
bool InsideMacroInstantiation() {return !ActiveMacros.empty();}
|
||||
|
||||
/// \brief Handle entry to macro instantiation.
|
||||
///
|
||||
/// \param M The macro.
|
||||
/// \param NameLoc Instantiation location.
|
||||
bool HandleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc);
|
||||
|
||||
/// \brief Handle exit from macro instantiation.
|
||||
void HandleMacroExit();
|
||||
|
||||
/// \brief Extract AsmTokens for a macro argument. If the argument delimiter
|
||||
/// is initially unknown, set it to AsmToken::Eof. It will be set to the
|
||||
/// correct delimiter by the method.
|
||||
bool ParseMacroArgument(MCAsmMacroArgument &MA,
|
||||
AsmToken::TokenKind &ArgumentDelimiter);
|
||||
|
||||
/// \brief Parse all macro arguments for a given macro.
|
||||
bool ParseMacroArguments(const MCAsmMacro *M, MCAsmMacroArguments &A);
|
||||
|
||||
void PrintMacroInstantiations();
|
||||
void PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Msg,
|
||||
ArrayRef<SMRange> Ranges = ArrayRef<SMRange>()) const {
|
||||
|
@ -259,8 +301,6 @@ private:
|
|||
/// location.
|
||||
void JumpToLoc(SMLoc Loc, int InBuffer=-1);
|
||||
|
||||
bool ParseMacroArguments(const MCAsmMacro *M, MCAsmMacroArguments &A);
|
||||
|
||||
/// \brief Parse up to the end of statement and a return the contents from the
|
||||
/// current token until the end of the statement; the current token on exit
|
||||
/// will be either the EndOfStatement or EOF.
|
||||
|
|
Loading…
Reference in New Issue