mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-19 14:16:41 +00:00
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>
This commit is contained in:
1 parent
8990ccd05a
commit
807ef98758
13 files changed
+359
-490
No files matched your search
@@ -0,0 +1,20 @@
|
||||
// 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
|
||||
Reference in new issue
Block a user