Files
carbon-lang/explorer/ast/ast_rtti.cpp
T
Richard SmithandChandler Carruth 807ef98758 Replace RTTI generation script with macros. (#2703)
This keeps all of our C++ code written in C++ source files, and avoids the increasing size of the RTTI generation script we'd started to see in #2699.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-03-30 14:16:44 -07:00

21 lines
781 B
C++

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