node_stack.cpp 841 B

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