mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:40:11 +01:00
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.
39 lines
885 B
C++
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_
|