ast_rtti.cpp 724 B

12345678910111213141516171819
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "explorer/ast/ast_rtti.h"
  5. namespace Carbon {
  6. // Define kind names for the base enumeration type.
  7. CARBON_DEFINE_ENUM_CLASS_NAMES(AstRttiNodeKind) = {
  8. CARBON_AST_FOR_EACH_FINAL_CLASS(CARBON_ENUM_CLASS_NAME_STRING)};
  9. // For other kind enumerations, reuse the same table.
  10. #define DEFINE_NAME_FUNCTION(C) \
  11. CARBON_ENUM_NAME_FUNCTION(C##Kind) { \
  12. return AstRttiNodeKind(static_cast<const C##Kind&>(*this)).name(); \
  13. }
  14. } // namespace Carbon