From: Owen Avery Date: Tue, 14 Mar 2023 21:35:16 +0000 (-0400) Subject: gccrs: HIR::AltPattern fixes X-Git-Tag: basepoints/gcc-15~2785 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb5d51879329252b09415ca2c101867f09f1c741;p=thirdparty%2Fgcc.git gccrs: 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 --- diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h index 17921cc0391c..9540070906e6 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> &get_alts () { return alts; } + const std::vector> &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 8b10b0bcc819..926712ccfcd6 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) {