@@ -585,6 +585,8 @@ private:
// FIXME: Documentation
tl::optional<std::pair<Node &, std::string>> dfs (Node &starting_point,
NodeId to_find);
+ // FIXME: Documentation
+ tl::optional<Rib &> dfs_rib (Node &starting_point, NodeId to_find);
};
} // namespace Resolver2_0
@@ -532,11 +532,29 @@ ForeverStack<N>::to_canonical_path (NodeId id)
template <Namespace N>
tl::optional<Rib &>
-ForeverStack<N>::to_rib (NodeId rib_id)
+ForeverStack<N>::dfs_rib (ForeverStack<N>::Node &starting_point, NodeId to_find)
{
+ if (starting_point.id == to_find)
+ return starting_point.rib;
+
+ for (auto &child : starting_point.children)
+ {
+ auto candidate = dfs_rib (child.second, to_find);
+
+ if (candidate.has_value ())
+ return candidate;
+ }
+
return tl::nullopt;
}
+template <Namespace N>
+tl::optional<Rib &>
+ForeverStack<N>::to_rib (NodeId rib_id)
+{
+ return dfs_rib (root, rib_id);
+}
+
template <Namespace N>
void
ForeverStack<N>::stream_rib (std::stringstream &stream, const Rib &rib,
From: Arthur Cohen <arthur.cohen@embecosm.com> gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: New method. * resolve/rust-forever-stack.hxx: Likewise. --- gcc/rust/resolve/rust-forever-stack.h | 2 ++ gcc/rust/resolve/rust-forever-stack.hxx | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-)