semantics_node_stack.cpp 922 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 "toolchain/semantics/semantics_node.h"
  6. namespace Carbon {
  7. auto SemanticsNodeStack::PrintForStackDump(llvm::raw_ostream& output) const
  8. -> void {
  9. output << "SemanticsNodeStack:\n";
  10. for (int i = 0; i < static_cast<int>(stack_.size()); ++i) {
  11. const auto& entry = stack_[i];
  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