Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.4 KiB

  1. //===-- llvm/MC/MCAsmParserExtension.h - Asm Parser Hooks -------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H
  10. #define LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H
  11. #include "llvm/ADT/StringRef.h"
  12. #include "llvm/MC/MCParser/MCAsmParser.h"
  13. #include "llvm/Support/SMLoc.h"
  14. namespace llvm {
  15. class Twine;
  16. /// \brief Generic interface for extending the MCAsmParser,
  17. /// which is implemented by target and object file assembly parser
  18. /// implementations.
  19. class MCAsmParserExtension {
  20. MCAsmParserExtension(const MCAsmParserExtension &) LLVM_DELETED_FUNCTION;
  21. void operator=(const MCAsmParserExtension &) LLVM_DELETED_FUNCTION;
  22. MCAsmParser *Parser;
  23. protected:
  24. MCAsmParserExtension();
  25. // Helper template for implementing static dispatch functions.
  26. template<typename T, bool (T::*Handler)(StringRef, SMLoc)>
  27. static bool HandleDirective(MCAsmParserExtension *Target,
  28. StringRef Directive,
  29. SMLoc DirectiveLoc) {
  30. T *Obj = static_cast<T*>(Target);
  31. return (Obj->*Handler)(Directive, DirectiveLoc);
  32. }
  33. bool BracketExpressionsSupported;
  34. public:
  35. virtual ~MCAsmParserExtension();
  36. /// \brief Initialize the extension for parsing using the given \p Parser.
  37. /// The extension should use the AsmParser interfaces to register its
  38. /// parsing routines.
  39. virtual void Initialize(MCAsmParser &Parser);
  40. /// @name MCAsmParser Proxy Interfaces
  41. /// @{
  42. MCContext &getContext() { return getParser().getContext(); }
  43. MCAsmLexer &getLexer() { return getParser().getLexer(); }
  44. MCAsmParser &getParser() { return *Parser; }
  45. SourceMgr &getSourceManager() { return getParser().getSourceManager(); }
  46. MCStreamer &getStreamer() { return getParser().getStreamer(); }
  47. bool Warning(SMLoc L, const Twine &Msg) {
  48. return getParser().Warning(L, Msg);
  49. }
  50. bool Error(SMLoc L, const Twine &Msg) {
  51. return getParser().Error(L, Msg);
  52. }
  53. bool TokError(const Twine &Msg) {
  54. return getParser().TokError(Msg);
  55. }
  56. const AsmToken &Lex() { return getParser().Lex(); }
  57. const AsmToken &getTok() { return getParser().getTok(); }
  58. bool HasBracketExpressions() const { return BracketExpressionsSupported; }
  59. /// @}
  60. };
  61. } // End llvm namespace
  62. #endif