public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] HIR: Add RangePatternBoundType and helpers
@ 2022-06-08 12:47 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bd90e61b2b2555ef0c17b832060c537c5c10cb8e

commit bd90e61b2b2555ef0c17b832060c537c5c10cb8e
Author: David Faust <david.faust@oracle.com>
Date:   Thu May 12 15:47:17 2022 -0700

    HIR: Add RangePatternBoundType and helpers

Diff:
---
 gcc/rust/hir/tree/rust-hir-pattern.h | 44 ++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/gcc/rust/hir/tree/rust-hir-pattern.h b/gcc/rust/hir/tree/rust-hir-pattern.h
index 880fc3e2e48..7129b5a3684 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 */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:47 [gcc/devel/rust/master] HIR: Add RangePatternBoundType and helpers Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).