mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Refactor NodeCategory to provide a class API (#4004)
Mirroring #4003 for NodeCategory. Note we template a lot more on NodeCategory's enum, so this is a slightly more awkward delta. Also, switch from Enum in KeywordModifierSet to RawEnumType for consistency with EnumBase. The templating on NodeCategory had me thinking about that more.
This commit is contained in:
@@ -10,16 +10,15 @@
|
||||
|
||||
namespace Carbon::Parse {
|
||||
|
||||
auto operator<<(llvm::raw_ostream& output, NodeCategory category)
|
||||
-> llvm::raw_ostream& {
|
||||
if (!category) {
|
||||
output << "<none>";
|
||||
auto NodeCategory::Print(llvm::raw_ostream& out) const -> void {
|
||||
if (!value_) {
|
||||
out << "<none>";
|
||||
} else {
|
||||
llvm::ListSeparator sep("|");
|
||||
|
||||
#define CARBON_NODE_CATEGORY(Name) \
|
||||
if (!!(category & NodeCategory::Name)) { \
|
||||
output << sep << #Name; \
|
||||
#define CARBON_NODE_CATEGORY(Name) \
|
||||
if (value_ & NodeCategory::Name) { \
|
||||
out << sep << #Name; \
|
||||
}
|
||||
CARBON_NODE_CATEGORY(Decl);
|
||||
CARBON_NODE_CATEGORY(Expr);
|
||||
@@ -31,7 +30,6 @@ auto operator<<(llvm::raw_ostream& output, NodeCategory category)
|
||||
CARBON_NODE_CATEGORY(Statement);
|
||||
#undef CARBON_NODE_CATEGORY
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
CARBON_DEFINE_ENUM_CLASS_NAMES(NodeKind) = {
|
||||
|
||||
Reference in New Issue
Block a user