mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:40:11 +01:00
Thought this might be interesting for you to allow more continuous
stream use. Also eliminates the need for `DumpNoNewline`.
```
expr Dump(context, complete_type_id)
(std::string) $0 = "type(inst1553): <builtin i32>; {kind: IntType, arg0: signed, arg1: inst1508, type: type(TypeType)}"
complete_type_id.Dump()
(std::string) $1 = "type(inst1553)"
expr Dump(context, specific_id)
(std::string) $2 = "specific166: {generic: generic0, args: inst_block772}"
expr Dump(context, query_self_const_id)
(std::string) $3 = "concrete_constant(inst1510): {kind: ClassType, arg0: class0, arg1: specific166, type: type(TypeType)}"
expr Dump(context, MakeFacetTypeId(arg))
(std::string) $4 = "facet_type22: {impls interface: interface10}
- interface10: {name: name26, parent_scope: name_scope0} `BitAnd`
complete: complete_facet_type22
- interface10: {name: name26, parent_scope: name_scope0} `BitAnd` (to impl)"
```
---------
Co-authored-by: Dana Jansens <danakj@orodu.net>
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
// This library contains functions to assist dumping objects to stderr during
|
|
// interactive debugging. Functions named `Dump` are intended for direct use by
|
|
// developers, and should use overload resolution to determine which will be
|
|
// invoked. The debugger should do namespace resolution automatically. For
|
|
// example:
|
|
//
|
|
// - lldb: `expr Dump(tree, id)`
|
|
// - gdb: `call Dump(tree, id)`
|
|
//
|
|
// The `DumpNoNewline` functions are helpers that exclude a trailing newline.
|
|
// They're intended to be composed by `Dump` function implementations.
|
|
|
|
#ifndef CARBON_TOOLCHAIN_PARSE_DUMP_H_
|
|
#define CARBON_TOOLCHAIN_PARSE_DUMP_H_
|
|
|
|
#ifndef NDEBUG
|
|
|
|
#include "toolchain/parse/tree.h"
|
|
|
|
namespace Carbon::Parse {
|
|
|
|
auto Dump(const Tree& tree, Lex::TokenIndex token) -> std::string;
|
|
auto Dump(const Tree& tree, NodeId node_id) -> std::string;
|
|
|
|
} // namespace Carbon::Parse
|
|
|
|
#endif // NDEBUG
|
|
|
|
#endif // CARBON_TOOLCHAIN_PARSE_DUMP_H_
|