Skip to content

Commit

Permalink
Add debug dump to old name resolver
Browse files Browse the repository at this point in the history
It might be necessary to compare both name resolution' internal states
during the transition. This new debug representation could help with
that.

gcc/rust/ChangeLog:

	* resolve/rust-name-resolver.h: Add new degug dump for old name
	resolver.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
  • Loading branch information
P-E-P committed Dec 11, 2024
1 parent 9d29160 commit 6e9f06c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions gcc/rust/resolve/rust-name-resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,41 @@ class Resolver
void insert_captured_item (NodeId id);
const std::set<NodeId> &get_captures (NodeId id) const;

std::string as_debug_string () const
{
std::stringstream ss;

ss << "Names:\n";
for (auto &n : name_ribs)
{
ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
<< "\n";
}
ss << "Types:\n";
for (auto &n : type_ribs)
{
ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
<< "\n";
}
ss << "Macros:\n";

for (auto &n : macro_ribs)
{
ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
<< "\n";
}

ss << "Labels:\n";

for (auto &n : label_ribs)
{
ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
<< "\n";
}

return ss.str ();
}

protected:
bool decl_needs_capture (NodeId decl_rib_node_id, NodeId closure_rib_node_id,
const Scope &scope);
Expand Down

0 comments on commit 6e9f06c

Please sign in to comment.