}
template <Namespace N>
-inline tl::optional<NodeId>
+tl::optional<NodeId>
ForeverStack<N>::get (const Identifier &name)
{
tl::optional<NodeId> resolved_node = tl::nullopt;
return resolved_node;
}
+template <>
+tl::optional<NodeId> inline ForeverStack<Namespace::Labels>::get (
+ const Identifier &name)
+{
+ tl::optional<NodeId> resolved_node = tl::nullopt;
+
+ reverse_iter ([&resolved_node, &name] (Node ¤t) {
+ // looking up for labels cannot go through function ribs
+ // TODO: What other ribs?
+ if (current.rib.kind == Rib::Kind::Function)
+ return KeepGoing::No;
+
+ auto candidate = current.rib.get (name.as_string ());
+
+ // FIXME: Factor this in a function with the generic `get`
+ return candidate.map_or (
+ [&resolved_node] (NodeId found) {
+ resolved_node = found;
+
+ return KeepGoing::No;
+ },
+ KeepGoing::Yes);
+ });
+
+ return resolved_node;
+}
+
/* Check if an iterator points to the last element */
template <typename I, typename C>
static bool