]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
HIR::AltPattern fixes
authorOwen Avery <powerboat9.gamer@gmail.com>
Tue, 14 Mar 2023 21:35:16 +0000 (17:35 -0400)
committerPhilip Herron <philip.herron@embecosm.com>
Wed, 15 Mar 2023 10:23:29 +0000 (10:23 +0000)
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>
gcc/rust/hir/tree/rust-hir-pattern.h
gcc/rust/hir/tree/rust-hir.cc

index 63725fa79d843ce2b1e3784f6a7aa403afd94506..d62db9b327eef80e898aa560c1b61f213698948d 100644 (file)
@@ -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;
index 4aa9d7e822765c42ef2904357d4aae0ca5a9a466..1c168db77930da2692838c5f6b13664ea404723e 100644 (file)
@@ -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)
 {