semantics_node_stack.cpp 909 B

1234567891011121314151617181920212223242526272829
  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. #include "toolchain/semantics/semantics_node_stack.h"
  5. #include "llvm/ADT/STLExtras.h"
  6. #include "toolchain/semantics/semantics_node.h"
  7. namespace Carbon {
  8. auto SemanticsNodeStack::PrintForStackDump(llvm::raw_ostream& output) const
  9. -> void {
  10. output << "SemanticsNodeStack:\n";
  11. for (auto [i, entry] : llvm::enumerate(stack_)) {
  12. auto parse_node_kind = parse_tree_->node_kind(entry.parse_node);
  13. output << "\t" << i << ".\t" << parse_node_kind;
  14. if (parse_node_kind == ParseNodeKind::PatternBinding) {
  15. output << " -> " << entry.name_id;
  16. } else {
  17. if (entry.node_id.is_valid()) {
  18. output << " -> " << entry.node_id;
  19. }
  20. }
  21. output << "\n";
  22. }
  23. }
  24. } // namespace Carbon