diff options
author | David Faust <david.faust@oracle.com> | 2022-05-12 15:47:17 -0700 |
---|---|---|
committer | David Faust <david.faust@oracle.com> | 2022-05-12 15:47:17 -0700 |
commit | bd90e61b2b2555ef0c17b832060c537c5c10cb8e (patch) | |
tree | 9006f55b32a5f690b220a04d3baa9059601806f6 /gcc | |
parent | c31d0c5f78f038baa48cb68f26ce84ed31ce3732 (diff) | |
download | gcc-bd90e61b2b2555ef0c17b832060c537c5c10cb8e.zip gcc-bd90e61b2b2555ef0c17b832060c537c5c10cb8e.tar.gz gcc-bd90e61b2b2555ef0c17b832060c537c5c10cb8e.tar.bz2 |
HIR: Add RangePatternBoundType and helpers
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-pattern.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h index 880fc3e..7129b5a 100644 --- a/gcc/rust/hir/tree/rust-hir-pattern.h +++ b/gcc/rust/hir/tree/rust-hir-pattern.h @@ -197,6 +197,13 @@ protected: class RangePatternBound { public: + enum RangePatternBoundType + { + LITERAL, + PATH, + QUALPATH + }; + virtual ~RangePatternBound () {} // Unique pointer custom clone function @@ -210,6 +217,8 @@ public: virtual void accept_vis (HIRFullVisitor &vis) = 0; + virtual RangePatternBoundType get_bound_type () const = 0; + protected: // pure virtual as RangePatternBound is abstract virtual RangePatternBound *clone_range_pattern_bound_impl () const = 0; @@ -238,8 +247,15 @@ public: Location get_locus () const { return locus; } + Literal get_literal () const { return literal; } + void accept_vis (HIRFullVisitor &vis) override; + RangePatternBoundType get_bound_type () const override + { + return RangePatternBoundType::LITERAL; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ @@ -264,8 +280,16 @@ public: Location get_locus () const { return path.get_locus (); } + PathInExpression &get_path () { return path; } + const PathInExpression &get_path () const { return path; } + void accept_vis (HIRFullVisitor &vis) override; + RangePatternBoundType get_bound_type () const override + { + return RangePatternBoundType::PATH; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ @@ -294,6 +318,14 @@ public: void accept_vis (HIRFullVisitor &vis) override; + QualifiedPathInExpression &get_qualified_path () { return path; } + const QualifiedPathInExpression &get_qualified_path () const { return path; } + + RangePatternBoundType get_bound_type () const override + { + return RangePatternBoundType::QUALPATH; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ @@ -368,6 +400,18 @@ public: return PatternType::RANGE; } + std::unique_ptr<RangePatternBound> &get_lower_bound () + { + rust_assert (lower != nullptr); + return lower; + } + + std::unique_ptr<RangePatternBound> &get_upper_bound () + { + rust_assert (upper != nullptr); + return upper; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ |