node_kind.h 885 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_SEMANTICS_NODE_KIND_H_
  5. #define CARBON_TOOLCHAIN_SEMANTICS_NODE_KIND_H_
  6. #include <cstdint>
  7. #include "common/ostream.h"
  8. namespace Carbon::Semantics {
  9. // Type-safe storage of Node IDs.
  10. struct NodeId {
  11. explicit NodeId(int32_t id) : id(id) {}
  12. void Print(llvm::raw_ostream& out) const { out << "%" << id; }
  13. // Comparison to help tests.
  14. auto operator==(int32_t other) const -> bool { return id == other; }
  15. int32_t id;
  16. };
  17. // Meta node information for declarations.
  18. enum class NodeKind {
  19. BinaryOperator,
  20. Function,
  21. IntegerLiteral,
  22. Return,
  23. SetName,
  24. Invalid,
  25. };
  26. } // namespace Carbon::Semantics
  27. #endif // CARBON_TOOLCHAIN_SEMANTICS_NODE_KIND_H_