diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-03-14 17:35:16 -0400 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2023-03-15 10:23:29 +0000 |
commit | 26e4aa3cd57f9e36b7c6404fab6f0ace1e5e3576 (patch) | |
tree | 3a635f35e6adccfe279a27343b5efad836a53a42 | |
parent | a1f940d193c6cdb13483690a4f4a7d501ad7040e (diff) | |
download | gcc-26e4aa3cd57f9e36b7c6404fab6f0ace1e5e3576.zip gcc-26e4aa3cd57f9e36b7c6404fab6f0ace1e5e3576.tar.gz gcc-26e4aa3cd57f9e36b7c6404fab6f0ace1e5e3576.tar.bz2 |
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 63725fa..d62db9b 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 4aa9d7e..1c168db 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); |