]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Push ribs by kind rather than by value
authorOwen Avery <powerboat9.gamer@gmail.com>
Mon, 11 Nov 2024 21:37:38 +0000 (16:37 -0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:32:56 +0000 (12:32 +0100)
gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h
(ForeverStack::push): Accept argument of type Rib::Kind rather
than Rib.
* resolve/rust-forever-stack.hxx
(ForeverStack::push): Likewise.
* resolve/rust-name-resolution-context.cc
(NameResolutionContext::scoped): Likewise.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::scoped): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
gcc/rust/resolve/rust-forever-stack.h
gcc/rust/resolve/rust-forever-stack.hxx
gcc/rust/resolve/rust-name-resolution-context.cc
gcc/rust/resolve/rust-name-resolution-context.h

index 28509259497b88a41f8ff0e0423d32f6f3b5d753..c548eeae087940aa20dd2e2a6bf83e1882ab9c67 100644 (file)
@@ -416,7 +416,7 @@ public:
    * @param path An optional path if the Rib was created due to a "named"
    *        lexical scope, like a module's.
    */
-  void push (Rib rib, NodeId id, tl::optional<Identifier> path = {});
+  void push (Rib::Kind rib_kind, NodeId id, tl::optional<Identifier> path = {});
 
   /**
    * Pop the innermost Rib from the stack
index 31f8ba498b3298740c4c91f03e3333df7d163f58..58164a4d3285f0e4b83bacc24b287eeddb47d27e 100644 (file)
@@ -52,9 +52,10 @@ ForeverStack<N>::Node::insert_child (Link link, Node child)
 
 template <Namespace N>
 void
-ForeverStack<N>::push (Rib rib, NodeId id, tl::optional<Identifier> path)
+ForeverStack<N>::push (Rib::Kind rib_kind, NodeId id,
+                      tl::optional<Identifier> path)
 {
-  push_inner (rib, Link (id, path));
+  push_inner (rib_kind, Link (id, path));
 }
 
 template <Namespace N>
index 9bfaa094abe122914a4b8194cb294a249b9dff7c..1b375213878523014bb7df96dec711f8c7a14cb2 100644 (file)
@@ -103,13 +103,13 @@ NameResolutionContext::lookup (NodeId usage) const
 }
 
 void
-NameResolutionContext::scoped (Rib rib, NodeId id,
+NameResolutionContext::scoped (Rib::Kind rib_kind, NodeId id,
                               std::function<void (void)> lambda,
                               tl::optional<Identifier> path)
 {
-  values.push (rib, id, path);
-  types.push (rib, id, path);
-  macros.push (rib, id, path);
+  values.push (rib_kind, id, path);
+  types.push (rib_kind, id, path);
+  macros.push (rib_kind, id, path);
   // labels.push (rib, id);
 
   lambda ();
@@ -121,17 +121,18 @@ NameResolutionContext::scoped (Rib rib, NodeId id,
 }
 
 void
-NameResolutionContext::scoped (Rib rib, Namespace ns, NodeId scope_id,
+NameResolutionContext::scoped (Rib::Kind rib_kind, Namespace ns,
+                              NodeId scope_id,
                               std::function<void (void)> lambda,
                               tl::optional<Identifier> path)
 {
   switch (ns)
     {
     case Namespace::Values:
-      values.push (rib, scope_id, path);
+      values.push (rib_kind, scope_id, path);
       break;
     case Namespace::Types:
-      types.push (rib, scope_id, path);
+      types.push (rib_kind, scope_id, path);
       break;
     case Namespace::Labels:
     case Namespace::Macros:
index cd6fa931be511388c4316b33bec63e63332d2d26..183ce7f3c2e433b6aa2484242c7d02926b19041d 100644 (file)
@@ -185,8 +185,8 @@ public:
    * function. This variant of the function enters a new scope in *all*
    * namespaces, while the second variant enters a scope in *one* namespace.
    *
-   * @param rib New `Rib` to create when entering this scope. A function `Rib`,
-   *        or an item `Rib`... etc
+   * @param rib_kind New `Rib` to create when entering this scope. A function
+   *        `Rib`, or an item `Rib`... etc
    * @param scope_id node ID of the scope we are entering, e.g the block's
    *        `NodeId`.
    * @param lambda Function to run within that scope
@@ -196,9 +196,10 @@ public:
    */
   // FIXME: Do we want to handle something in particular for expected within the
   // scoped lambda?
-  void scoped (Rib rib, NodeId scope_id, std::function<void (void)> lambda,
+  void scoped (Rib::Kind rib_kind, NodeId scope_id,
+              std::function<void (void)> lambda,
               tl::optional<Identifier> path = {});
-  void scoped (Rib rib, Namespace ns, NodeId scope_id,
+  void scoped (Rib::Kind rib_kind, Namespace ns, NodeId scope_id,
               std::function<void (void)> lambda,
               tl::optional<Identifier> path = {});