BfDemangler.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #pragma once
  2. #include "BeefySysLib/Common.h"
  3. #include "../DebugCommon.h"
  4. NS_BF_BEGIN
  5. typedef Array<String> SubstituteList;
  6. class DemangleBase
  7. {
  8. public:
  9. DbgLanguage mLanguage;
  10. int mCurIdx;
  11. String mResult;
  12. bool mFailed;
  13. String mMangledName;
  14. SubstituteList mSubstituteList;
  15. bool mInArgs;
  16. bool mBeefFixed;
  17. public:
  18. DemangleBase();
  19. bool Failed();
  20. void Require(bool result);
  21. };
  22. class DwDemangler : public DemangleBase
  23. {
  24. public:
  25. SubstituteList mTemplateList;
  26. bool mIsFirstName;
  27. int mTemplateDepth;
  28. bool mOmitSubstituteAdd;
  29. bool mCaptureTargetType;
  30. bool mFunctionPopSubstitute;
  31. bool mRawDemangle;
  32. public:
  33. bool DemangleEnd();
  34. bool DemangleArrayType(StringImpl& outName);
  35. bool DemangleBuiltinType(StringImpl& outName);
  36. bool DemangleFunctionType(StringImpl& outName);
  37. bool DemangleSourceName(StringImpl& outName);
  38. bool DemangleRefQualifier(StringImpl& outName);
  39. bool DemangleType(StringImpl& outName);
  40. bool DemangleNestedName(StringImpl& outName);
  41. bool DemangleCVQualifiers(StringImpl& outName);
  42. bool DemangleOperatorName(StringImpl& outName);
  43. bool DemangleExprPriamry(StringImpl& outName);
  44. bool DemangleTemplateArgPack(StringImpl& outName);
  45. bool DemangleTemplateArg(StringImpl& outName);
  46. bool DemangleTemplateArgs(StringImpl& outName);
  47. bool DemangleUnqualifiedName(StringImpl& outName);
  48. bool DemangleInternalName(StringImpl& outName);
  49. bool DemangleSubstitution(StringImpl& outName);
  50. bool DemangleTemplateParam(StringImpl& outName);
  51. bool DemangleUnscopedName(StringImpl& outName);
  52. bool DemangleClassEnumType(StringImpl& outName);
  53. bool DemangleLocalName(StringImpl& outName);
  54. bool DemangleName(StringImpl& outName, bool* outHasTemplateArgs = NULL);
  55. bool DemangleFunction(StringImpl& outName);
  56. public:
  57. DwDemangler();
  58. String Demangle(const StringImpl& mangledName);
  59. };
  60. class MsDemangler : public DemangleBase
  61. {
  62. public:
  63. int mCurIdx;
  64. public:
  65. int DemangleNumber();
  66. bool DemangleString(StringImpl& outName);
  67. bool DemangleTemplateName(StringImpl& outName, String* primaryName = NULL);
  68. bool DemangleCV(StringImpl& outName);
  69. bool DemangleModifiedType(StringImpl& outName, bool isPtr);
  70. bool DemangleType(StringImpl& outName);
  71. bool DemangleScopedName(StringImpl& outName, String* primaryName = NULL);
  72. bool DemangleName(StringImpl& outName);
  73. static bool IsData(const StringImpl& mangledName);
  74. public:
  75. MsDemangler();
  76. String Demangle(const StringImpl& mangledName);
  77. };
  78. class MsDemangleScanner : public DemangleBase
  79. {
  80. public:
  81. bool mIsData;
  82. public:
  83. int DemangleNumber();
  84. bool DemangleString();
  85. bool DemangleTemplateName();
  86. bool DemangleCV();
  87. bool DemangleModifiedType(bool isPtr);
  88. bool DemangleType();
  89. bool DemangleScopedName();
  90. bool DemangleName();
  91. public:
  92. MsDemangleScanner();
  93. void Process(const StringImpl& mangledName);
  94. };
  95. class BfDemangler
  96. {
  97. public:
  98. enum Flags
  99. {
  100. Flag_None,
  101. Flag_CaptureTargetType = 1,
  102. Flag_RawDemangle = 2,
  103. Flag_BeefFixed = 4
  104. };
  105. public:
  106. static String Demangle(const StringImpl& mangledName, DbgLanguage language, Flags flags = Flag_None);
  107. static bool IsData(const StringImpl& mangledName);
  108. };
  109. NS_BF_END