public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8120] gccrs: Add some reference getter
@ 2024-01-16 18:15 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:15 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7065e2dbfee8bd4088c8361158420b6667dfb8ff

commit r14-8120-g7065e2dbfee8bd4088c8361158420b6667dfb8ff
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Wed Oct 25 16:53:59 2023 +0200

    gccrs: Add some reference getter
    
    Visitor pattern requires a getter to children using a mutable reference.
    
    gcc/rust/ChangeLog:
    
            * ast/rust-ast.h: Add some missing mutable reference getters.
            * ast/rust-expr.h: Likewise.
            * ast/rust-item.h: Likewise.
            * ast/rust-path.h: Likewise.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 gcc/rust/ast/rust-ast.h  |  4 ++++
 gcc/rust/ast/rust-expr.h |  6 ++++++
 gcc/rust/ast/rust-item.h | 22 +++++++++++++++++++---
 gcc/rust/ast/rust-path.h |  2 ++
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index c4dbd7ef424..a497ccd8467 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1408,6 +1408,10 @@ class LifetimeParam : public GenericParam
 public:
   Lifetime get_lifetime () const { return lifetime; }
 
+  Lifetime &get_lifetime () { return lifetime; }
+
+  Attribute &get_outer_attribute () { return outer_attr; }
+
   // Returns whether the lifetime param has any lifetime bounds.
   bool has_lifetime_bounds () const { return !lifetime_bounds.empty (); }
 
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index bd59f81b562..f0d663bf6ca 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -226,6 +226,8 @@ public:
 
   LiteralExpr get_literal () const { return lit_expr; }
 
+  LiteralExpr &get_literal () { return lit_expr; }
+
   void accept_vis (ASTVisitor &vis) override;
 
   bool check_cfg_predicate (const Session &session) const override;
@@ -256,8 +258,12 @@ public:
 
   SimplePath get_path () const { return path; }
 
+  SimplePath &get_path () { return path; }
+
   LiteralExpr get_literal () const { return lit; }
 
+  LiteralExpr &get_literal () { return lit; }
+
   std::string as_string () const override
   {
     return path.as_string () + " = " + lit.as_string ();
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 57059eb0672..5af51bc35fc 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -77,6 +77,8 @@ public:
   // Returns whether the type param has an outer attribute.
   bool has_outer_attribute () const { return !outer_attr.is_empty (); }
 
+  Attribute &get_outer_attribute () { return outer_attr; }
+
   TypeParam (Identifier type_representation, location_t locus = UNDEF_LOCATION,
 	     std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds
 	     = std::vector<std::unique_ptr<TypeParamBound>> (),
@@ -472,6 +474,7 @@ public:
   bool get_is_mut () const { return is_mut; }
 
   Lifetime get_lifetime () const { return lifetime; }
+  Lifetime &get_lifetime () { return lifetime; }
 
   NodeId get_node_id () const { return node_id; }
 
@@ -915,7 +918,9 @@ public:
 
   location_t get_locus () const override final { return locus; }
 
-  FunctionQualifiers get_qualifiers () { return qualifiers; }
+  FunctionQualifiers get_qualifiers () const { return qualifiers; }
+
+  FunctionQualifiers &get_qualifiers () { return qualifiers; }
 
   Visibility &get_visibility () { return vis; }
   const Visibility &get_visibility () const { return vis; }
@@ -1299,6 +1304,8 @@ public:
     return path;
   }
 
+  SimplePath &get_path () { return path; }
+
   /* TODO: find way to ensure only PATH_PREFIXED glob_type has path - factory
    * methods? */
 protected:
@@ -1389,6 +1396,8 @@ public:
     return path;
   }
 
+  SimplePath &get_path () { return path; }
+
   std::vector<std::unique_ptr<UseTree>> &get_trees () { return trees; }
 
   const std::vector<std::unique_ptr<UseTree>> &get_trees () const
@@ -1451,6 +1460,8 @@ public:
     return path;
   }
 
+  SimplePath &get_path () { return path; }
+
   const Identifier &get_identifier () const
   {
     rust_assert (has_identifier ());
@@ -1677,6 +1688,8 @@ public:
 
   const FunctionQualifiers &get_qualifiers () const { return qualifiers; }
 
+  FunctionQualifiers &get_qualifiers () { return qualifiers; }
+
   Identifier get_function_name () const { return function_name; }
 
   // TODO: is this better? Or is a "vis_block" better?
@@ -2921,7 +2934,8 @@ public:
   // TODO: is this better? Or is a "vis_block" better?
   WhereClause &get_where_clause () { return where_clause; }
 
-  FunctionQualifiers get_qualifiers () { return qualifiers; }
+  FunctionQualifiers get_qualifiers () const { return qualifiers; }
+  FunctionQualifiers &get_qualifiers () { return qualifiers; }
 };
 
 // Actual trait item function declaration within traits
@@ -3137,7 +3151,9 @@ public:
   SelfParam &get_self_param () { return self_param; }
   const SelfParam &get_self_param () const { return self_param; }
 
-  FunctionQualifiers get_qualifiers () { return qualifiers; }
+  FunctionQualifiers get_qualifiers () const { return qualifiers; }
+
+  FunctionQualifiers &get_qualifiers () { return qualifiers; }
 };
 
 // Actual trait item method declaration within traits
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 9279fdd8c7d..b76664fa7dd 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -350,6 +350,8 @@ public:
 
   const Identifier &get_name () const { return name; }
 
+  Attribute &get_outer_attribute () { return outer_attr; }
+
   std::unique_ptr<AST::Type> &get_type ()
   {
     rust_assert (has_type ());

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

only message in thread, other threads:[~2024-01-16 18:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:15 [gcc r14-8120] gccrs: Add some reference getter 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).