aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Faust <david.faust@oracle.com>2022-05-12 15:46:43 -0700
committerDavid Faust <david.faust@oracle.com>2022-05-12 15:46:43 -0700
commitc31d0c5f78f038baa48cb68f26ce84ed31ce3732 (patch)
treeb617087637375bc74a911c79557d7faafc2dab61 /gcc
parentd4434b511a4e650e95c7a1de6810d8748c5d8a70 (diff)
downloadgcc-c31d0c5f78f038baa48cb68f26ce84ed31ce3732.zip
gcc-c31d0c5f78f038baa48cb68f26ce84ed31ce3732.tar.gz
gcc-c31d0c5f78f038baa48cb68f26ce84ed31ce3732.tar.bz2
ast: Add RangePatternBoundType and helpers
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-pattern.h28
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 */