aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2025-02-27 12:28:32 +0100
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2025-03-11 14:06:30 +0000
commit126680c6116cd7413b3163e41f1db968ce26666a (patch)
tree7c2d41b331a19e577ca76595fbdd73fe70e58056 /gcc
parent6029cc9f253124dad3495ee1b681641d588cafb0 (diff)
downloadgcc-126680c6116cd7413b3163e41f1db968ce26666a.zip
gcc-126680c6116cd7413b3163e41f1db968ce26666a.tar.gz
gcc-126680c6116cd7413b3163e41f1db968ce26666a.tar.bz2
Add rib kind debug representation
Rib kind had no string representation, and thus were not used in the debug string representation. gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Output rib kind. * resolve/rust-rib.h: Add function to get string representation from a rib kind. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/resolve/rust-forever-stack.hxx10
-rw-r--r--gcc/rust/resolve/rust-rib.h29
2 files changed, 36 insertions, 3 deletions
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx
index c2b348f..43061ff 100644
--- a/gcc/rust/resolve/rust-forever-stack.hxx
+++ b/gcc/rust/resolve/rust-forever-stack.hxx
@@ -781,13 +781,17 @@ ForeverStack<N>::stream_rib (std::stringstream &stream, const Rib &rib,
const std::string &next,
const std::string &next_next) const
{
+ std::string rib_kind = Rib::kind_to_string (rib.kind);
+ stream << next << "rib [" << rib_kind << "]: {";
if (rib.get_values ().empty ())
{
- stream << next << "rib: {},\n";
+ stream << "}\n";
return;
}
-
- stream << next << "rib: {\n";
+ else
+ {
+ stream << "\n";
+ }
for (const auto &kv : rib.get_values ())
stream << next_next << kv.first << ": " << kv.second.to_string () << "\n";
diff --git a/gcc/rust/resolve/rust-rib.h b/gcc/rust/resolve/rust-rib.h
index 9a046b2..da1838a 100644
--- a/gcc/rust/resolve/rust-rib.h
+++ b/gcc/rust/resolve/rust-rib.h
@@ -175,6 +175,35 @@ public:
ConstParamType,
} kind;
+ static std::string kind_to_string (Rib::Kind kind)
+ {
+ switch (kind)
+ {
+ case Rib::Kind::Normal:
+ return "Normal";
+ case Rib::Kind::Module:
+ return "Module";
+ case Rib::Kind::Function:
+ return "Function";
+ case Rib::Kind::ConstantItem:
+ return "ConstantItem";
+ case Rib::Kind::TraitOrImpl:
+ return "TraitOrImpl";
+ case Rib::Kind::Item:
+ return "Item";
+ case Rib::Kind::Closure:
+ return "Closure";
+ case Rib::Kind::MacroDefinition:
+ return "Macro definition";
+ case Rib::Kind::ForwardTypeParamBan:
+ return "Forward type param ban";
+ case Rib::Kind::ConstParamType:
+ return "Const Param Type";
+ default:
+ rust_unreachable ();
+ }
+ }
+
Rib (Kind kind);
Rib (Kind kind, std::string identifier, NodeId id);
Rib (Kind kind, std::unordered_map<std::string, NodeId> values);