public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] HIR: Add RangePatternBoundType and helpers
Date: Wed,  8 Jun 2022 12:47:01 +0000 (GMT)	[thread overview]
Message-ID: <20220608124701.9EA91380E18A@sourceware.org> (raw)

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 */


                 reply	other threads:[~2022-06-08 12:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608124701.9EA91380E18A@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).