diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-03-14 17:35:16 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:21:09 +0100 |
commit | fb5d51879329252b09415ca2c101867f09f1c741 (patch) | |
tree | d5714777cd1341615c23aaaf24654928b92b0544 | |
parent | 51ba68e38a04b1eecf7ad43c067ce18dc783e722 (diff) | |
download | gcc-fb5d51879329252b09415ca2c101867f09f1c741.zip gcc-fb5d51879329252b09415ca2c101867f09f1c741.tar.gz gcc-fb5d51879329252b09415ca2c101867f09f1c741.tar.bz2 |
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 <powerboat9.gamer@gmail.com>
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-pattern.h | 7 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir.cc | 25 |
2 files changed, 31 insertions, 1 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h index 17921cc..9540070 100644 --- a/gcc/rust/hir/tree/rust-hir-pattern.h +++ b/gcc/rust/hir/tree/rust-hir-pattern.h @@ -1314,7 +1314,6 @@ class AltPattern : public Pattern Analysis::NodeMapping mappings; public: -public: std::string as_string () const override; AltPattern (Analysis::NodeMapping mappings, @@ -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 8b10b0b..926712c 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -2413,6 +2413,19 @@ SlicePattern::as_string () const } 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 { std::string str; @@ -4479,6 +4492,12 @@ SlicePattern::accept_vis (HIRFullVisitor &vis) } void +AltPattern::accept_vis (HIRFullVisitor &vis) +{ + vis.visit (*this); +} + +void EmptyStmt::accept_vis (HIRFullVisitor &vis) { vis.visit (*this); @@ -4809,6 +4828,12 @@ SlicePattern::accept_vis (HIRPatternVisitor &vis) } void +AltPattern::accept_vis (HIRPatternVisitor &vis) +{ + vis.visit (*this); +} + +void RangePattern::accept_vis (HIRPatternVisitor &vis) { vis.visit (*this); |