Files
carbon-lang/toolchain/semantics/node_kind.h
T
Jon Ross-Perkins b80e294b6c Make structs to distinguish ID versus NodeStore index (#2171)
WDYT of this, to avoid raw int32_t indices? I was looking at the code again and found it hard to sort out. I think this doesn't have overhead.
2022-09-15 14:36:50 -07:00

39 lines
885 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
#ifndef CARBON_TOOLCHAIN_SEMANTICS_NODE_KIND_H_
#define CARBON_TOOLCHAIN_SEMANTICS_NODE_KIND_H_
#include <cstdint>
#include "common/ostream.h"
namespace Carbon::Semantics {
// Type-safe storage of Node IDs.
struct NodeId {
explicit NodeId(int32_t id) : id(id) {}
void Print(llvm::raw_ostream& out) const { out << "%" << id; }
// Comparison to help tests.
auto operator==(int32_t other) const -> bool { return id == other; }
int32_t id;
};
// Meta node information for declarations.
enum class NodeKind {
BinaryOperator,
Function,
IntegerLiteral,
Return,
SetName,
Invalid,
};
} // namespace Carbon::Semantics
#endif // CARBON_TOOLCHAIN_SEMANTICS_NODE_KIND_H_