diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-05-13 15:45:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-13 15:45:24 +0000 |
commit | e4213b9568ae8cb8a4e31326e0e78c79db0a99cc (patch) | |
tree | 95fa5b04afbe6b66a3faece7399782c8305dab11 /gcc/rust/ast/rust-pattern.h | |
parent | d4434b511a4e650e95c7a1de6810d8748c5d8a70 (diff) | |
parent | b1eb3e036c6fb5acc28c714375e6309fb5aa9ec8 (diff) | |
download | gcc-e4213b9568ae8cb8a4e31326e0e78c79db0a99cc.zip gcc-e4213b9568ae8cb8a4e31326e0e78c79db0a99cc.tar.gz gcc-e4213b9568ae8cb8a4e31326e0e78c79db0a99cc.tar.bz2 |
Merge #1248
1248: Support RangePatterns in matches r=dafaust a=dafaust
Add name resolution, lowering, type checking and compilation for `RangePattern`s in matches.
Co-authored-by: David Faust <david.faust@oracle.com>
Diffstat (limited to 'gcc/rust/ast/rust-pattern.h')
-rw-r--r-- | gcc/rust/ast/rust-pattern.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-pattern.h b/gcc/rust/ast/rust-pattern.h index a3193f7..247af5d 100644 --- a/gcc/rust/ast/rust-pattern.h +++ b/gcc/rust/ast/rust-pattern.h @@ -195,6 +195,13 @@ protected: class RangePatternBound { public: + enum RangePatternBoundType + { + LITERAL, + PATH, + QUALPATH + }; + virtual ~RangePatternBound () {} // Unique pointer custom clone function @@ -208,6 +215,8 @@ public: virtual void accept_vis (ASTVisitor &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; @@ -234,10 +243,19 @@ public: std::string as_string () const override; + Literal get_literal () const { return literal; } + + bool get_has_minus () const { return has_minus; } + Location get_locus () const { return locus; } void accept_vis (ASTVisitor &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 */ @@ -268,6 +286,11 @@ public: PathInExpression &get_path () { return path; } const PathInExpression &get_path () const { return path; } + RangePatternBoundType get_bound_type () const override + { + return RangePatternBoundType::PATH; + } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ @@ -300,6 +323,11 @@ public: 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 */ |