public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add ImplItemTypes enum to switch between HIR::ImplItem types
@ 2022-06-08 11:47 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 11:47 UTC (permalink / raw)
  To: gcc-cvs

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

commit b3e884c3e9d02b182469abff0fa7531ec8325a5e
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Thu Nov 4 12:12:15 2021 +0000

    Add ImplItemTypes enum to switch between HIR::ImplItem types

Diff:
---
 gcc/rust/hir/tree/rust-hir-item.h | 15 +++++++++++++++
 gcc/rust/hir/tree/rust-hir.h      | 17 +++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h
index c5a8d06a3da..0dd7ac80b65 100644
--- a/gcc/rust/hir/tree/rust-hir-item.h
+++ b/gcc/rust/hir/tree/rust-hir-item.h
@@ -1122,6 +1122,11 @@ public:
   // Returns whether function has a where clause.
   bool has_where_clause () const { return !where_clause.is_empty (); }
 
+  ImplItemType get_impl_item_type () const override final
+  {
+    return ImplItem::ImplItemType::FUNCTION;
+  }
+
   // Mega-constructor with all possible fields
   Function (Analysis::NodeMapping mappings, Identifier function_name,
 	    FunctionQualifiers qualifiers,
@@ -1273,6 +1278,11 @@ public:
   // Returns whether type alias has a where clause.
   bool has_where_clause () const { return !where_clause.is_empty (); }
 
+  ImplItemType get_impl_item_type () const override final
+  {
+    return ImplItem::ImplItemType::TYPE_ALIAS;
+  }
+
   // Mega-constructor with all possible fields
   TypeAlias (Analysis::NodeMapping mappings, Identifier new_type_name,
 	     std::vector<std::unique_ptr<GenericParam>> generic_params,
@@ -2075,6 +2085,11 @@ public:
     return get_mappings ();
   };
 
+  ImplItemType get_impl_item_type () const override final
+  {
+    return ImplItem::ImplItemType::CONSTANT;
+  }
+
 protected:
   /* Use covariance to implement clone function as returning this object
    * rather than base */
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index d7977b4f6f6..af18d804f42 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -642,11 +642,14 @@ public:
 
 class ImplItem
 {
-protected:
-  // Clone function implementation as pure virtual method
-  virtual ImplItem *clone_inherent_impl_item_impl () const = 0;
-
 public:
+  enum ImplItemType
+  {
+    FUNCTION,
+    TYPE_ALIAS,
+    CONSTANT
+  };
+
   virtual ~ImplItem () {}
 
   // Unique pointer custom clone function
@@ -662,6 +665,12 @@ public:
   virtual Analysis::NodeMapping get_impl_mappings () const = 0;
 
   virtual Location get_locus () const = 0;
+
+  virtual ImplItemType get_impl_item_type () const = 0;
+
+protected:
+  // Clone function implementation as pure virtual method
+  virtual ImplItem *clone_inherent_impl_item_impl () const = 0;
 };
 
 // A crate HIR object - holds all the data for a single compilation unit


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

only message in thread, other threads:[~2022-06-08 11: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 11:47 [gcc/devel/rust/master] Add ImplItemTypes enum to switch between HIR::ImplItem types 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).