public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8530] gccrs: ast: Change *Path nodes API
@ 2024-01-30 11:57 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-30 11:57 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c5925f349231155e48fa649f47b3c699ef4ba3b0

commit r14-8530-gc5925f349231155e48fa649f47b3c699ef4ba3b0
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Thu Aug 17 14:05:49 2023 +0200

    gccrs: ast: Change *Path nodes API
    
    gcc/rust/ChangeLog:
    
            * ast/rust-ast.h: Change Path API to be more consistent.
            * ast/rust-path.h: Likewise.
            * ast/rust-ast-collector.cc (TokenCollector::visit): Use new API.
            * resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Likewise.
            * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): Likewise.
            * resolve/rust-forever-stack.hxx: Likewise.

Diff:
---
 gcc/rust/ast/rust-ast-collector.cc        | 2 +-
 gcc/rust/ast/rust-ast.h                   | 2 +-
 gcc/rust/ast/rust-path.h                  | 9 +++++++++
 gcc/rust/resolve/rust-ast-resolve-item.cc | 2 +-
 gcc/rust/resolve/rust-ast-resolve-path.cc | 2 +-
 gcc/rust/resolve/rust-forever-stack.hxx   | 7 ++++---
 6 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-collector.cc b/gcc/rust/ast/rust-ast-collector.cc
index cb8dfd800162..7d3d3e204f7e 100644
--- a/gcc/rust/ast/rust-ast-collector.cc
+++ b/gcc/rust/ast/rust-ast-collector.cc
@@ -191,7 +191,7 @@ TokenCollector::visit (SimplePathSegment &segment)
     {
       push (Rust::Token::make (SUPER, segment.get_locus ()));
     }
-  else if (segment.is_lower_self ())
+  else if (segment.is_lower_self_seg ())
     {
       push (Rust::Token::make (SELF, segment.get_locus ()));
     }
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 4dc7f9710f3c..47c02d6ac8b8 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -399,7 +399,7 @@ public:
   {
     return as_string ().compare ("crate") == 0;
   }
-  bool is_lower_self () const { return as_string ().compare ("self") == 0; }
+  bool is_lower_self_seg () const { return as_string ().compare ("self") == 0; }
   bool is_big_self () const { return as_string ().compare ("Self") == 0; }
 };
 
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index b76664fa7ddb..ccac6303bb4b 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -536,6 +536,7 @@ public:
   {
     return !has_generic_args () && get_ident_segment ().is_crate_segment ();
   }
+
   bool is_lower_self_seg () const
   {
     return !has_generic_args () && get_ident_segment ().is_lower_self ();
@@ -646,6 +647,14 @@ public:
     outer_attrs = std::move (new_attrs);
   }
 
+  NodeId get_pattern_node_id () const { return get_node_id (); }
+
+  PathExprSegment &get_final_segment () { return get_segments ().back (); }
+  const PathExprSegment &get_final_segment () const
+  {
+    return get_segments ().back ();
+  }
+
 protected:
   /* Use covariance to implement clone function as returning this object
    * rather than base */
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index 1fc6b920c5e4..eaee5bc86061 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -1031,7 +1031,7 @@ ResolveItem::visit (AST::UseDeclaration &use_item)
       if (!ok)
 	continue;
 
-      const AST::SimplePathSegment &final_seg = path.get_final_segment ();
+      const AST::SimplePathSegment &final_seg = path.get_segments ().back ();
 
       auto decl
 	= CanonicalPath::new_seg (resolved_node_id, final_seg.as_string ());
diff --git a/gcc/rust/resolve/rust-ast-resolve-path.cc b/gcc/rust/resolve/rust-ast-resolve-path.cc
index fd2a844a506a..9e982d0610e4 100644
--- a/gcc/rust/resolve/rust-ast-resolve-path.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-path.cc
@@ -367,7 +367,7 @@ ResolvePath::resolve_path (AST::SimplePath *expr)
       //   	      is_first_segment ? "true" : "false",
       //   	      is_final_segment ? "true" : "false");
       if (resolved_node_id == UNKNOWN_NODEID && !is_first_segment
-	  && is_final_segment && segment.is_lower_self ())
+	  && is_final_segment && segment.is_lower_self_seg ())
 	{
 	  resolved_node_id = previous_resolved_node_id;
 	}
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx
index 8bdda67782a4..5acdf06c770c 100644
--- a/gcc/rust/resolve/rust-forever-stack.hxx
+++ b/gcc/rust/resolve/rust-forever-stack.hxx
@@ -313,7 +313,8 @@ ForeverStack<N>::find_starting_point (
   for (; !is_last (iterator, segments); iterator++)
     {
       auto seg = *iterator;
-      auto is_self_or_crate = seg.is_crate_path_seg () || seg.is_lower_self ();
+      auto is_self_or_crate
+	= seg.is_crate_path_seg () || seg.is_lower_self_seg ();
 
       // if we're after the first path segment and meet `self` or `crate`, it's
       // an error - we should only be seeing `super` keywords at this point
@@ -327,7 +328,7 @@ ForeverStack<N>::find_starting_point (
 	  iterator++;
 	  break;
 	}
-      if (seg.is_lower_self ())
+      if (seg.is_lower_self_seg ())
 	{
 	  // do nothing and exit
 	  iterator++;
@@ -371,7 +372,7 @@ ForeverStack<N>::resolve_segments (
       // check that we don't encounter *any* leading keywords afterwards
       if (check_leading_kw_at_start (seg, seg.is_crate_path_seg ()
 					    || seg.is_super_path_seg ()
-					    || seg.is_lower_self ()))
+					    || seg.is_lower_self_seg ()))
 	return tl::nullopt;
 
       tl::optional<typename ForeverStack<N>::Node &> child = tl::nullopt;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-30 11:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30 11:57 [gcc r14-8530] gccrs: ast: Change *Path nodes API Arthur Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).