node_stack.cpp 876 B

12345678910111213141516171819202122232425262728
  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/check/node_stack.h"
  5. #include "llvm/ADT/STLExtras.h"
  6. #include "toolchain/sem_ir/inst.h"
  7. namespace Carbon::Check {
  8. auto NodeStack::PrintForStackDump(llvm::raw_ostream& output) const -> void {
  9. output << "NodeStack:\n";
  10. for (auto [i, entry] : llvm::enumerate(stack_)) {
  11. auto parse_node_kind = parse_tree_->node_kind(entry.parse_node);
  12. output << "\t" << i << ".\t" << parse_node_kind;
  13. if (parse_node_kind == Parse::NodeKind::BindingPattern) {
  14. output << " -> " << entry.name_id;
  15. } else {
  16. if (entry.inst_id.is_valid()) {
  17. output << " -> " << entry.inst_id;
  18. }
  19. }
  20. output << "\n";
  21. }
  22. }
  23. } // namespace Carbon::Check