public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] HIR::AltPattern fixes
@ 2023-03-20  7:22 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-03-20  7:22 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:26e4aa3cd57f9e36b7c6404fab6f0ace1e5e3576

commit 26e4aa3cd57f9e36b7c6404fab6f0ace1e5e3576
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Tue Mar 14 17:35:16 2023 -0400

    HIR::AltPattern fixes
    
    gcc/rust/ChangeLog:
    
            * hir/tree/rust-hir-pattern.h
            (class AltPattern): Remove duplicate access specifier.
            (AltPattern::get_alts): Add.
            * hir/tree/rust-hir.cc
            (AltPattern::as_string): Add.
            (AltPattern::accept_vis): Add.
    
    Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

Diff:
---
 gcc/rust/hir/tree/rust-hir-pattern.h |  7 ++++++-
 gcc/rust/hir/tree/rust-hir.cc        | 25 +++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h
index 63725fa79d8..d62db9b327e 100644
--- a/gcc/rust/hir/tree/rust-hir-pattern.h
+++ b/gcc/rust/hir/tree/rust-hir-pattern.h
@@ -1313,7 +1313,6 @@ class AltPattern : public Pattern
   Location locus;
   Analysis::NodeMapping mappings;
 
-public:
 public:
   std::string as_string () const override;
 
@@ -1349,6 +1348,12 @@ public:
   AltPattern (AltPattern &&other) = default;
   AltPattern &operator= (AltPattern &&other) = default;
 
+  std::vector<std::unique_ptr<Pattern>> &get_alts () { return alts; }
+  const std::vector<std::unique_ptr<Pattern>> &get_alts () const
+  {
+    return alts;
+  }
+
   Location get_locus () const override { return locus; }
 
   void accept_vis (HIRFullVisitor &vis) override;
diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc
index 4aa9d7e8227..1c168db7793 100644
--- a/gcc/rust/hir/tree/rust-hir.cc
+++ b/gcc/rust/hir/tree/rust-hir.cc
@@ -2412,6 +2412,19 @@ SlicePattern::as_string () const
   return str;
 }
 
+std::string
+AltPattern::as_string () const
+{
+  std::string str ("AltPattern: ");
+
+  for (const auto &pattern : alts)
+    {
+      str += "\n " + pattern->as_string ();
+    }
+
+  return str;
+}
+
 std::string
 TuplePatternItemsMultiple::as_string () const
 {
@@ -4478,6 +4491,12 @@ SlicePattern::accept_vis (HIRFullVisitor &vis)
   vis.visit (*this);
 }
 
+void
+AltPattern::accept_vis (HIRFullVisitor &vis)
+{
+  vis.visit (*this);
+}
+
 void
 EmptyStmt::accept_vis (HIRFullVisitor &vis)
 {
@@ -4808,6 +4827,12 @@ SlicePattern::accept_vis (HIRPatternVisitor &vis)
   vis.visit (*this);
 }
 
+void
+AltPattern::accept_vis (HIRPatternVisitor &vis)
+{
+  vis.visit (*this);
+}
+
 void
 RangePattern::accept_vis (HIRPatternVisitor &vis)
 {

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

only message in thread, other threads:[~2023-03-20  7:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20  7:22 [gcc/devel/rust/master] HIR::AltPattern fixes Thomas Schwinge

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).