aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-11-04 12:12:15 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-11-04 12:12:15 +0000
commitb3e884c3e9d02b182469abff0fa7531ec8325a5e (patch)
treef9d4d61cf3e70a34509f2235cea085709d81d3cf
parent3dccdb1d6c57e983bed7135b4bc9ba7e1ae20fab (diff)
downloadgcc-b3e884c3e9d02b182469abff0fa7531ec8325a5e.zip
gcc-b3e884c3e9d02b182469abff0fa7531ec8325a5e.tar.gz
gcc-b3e884c3e9d02b182469abff0fa7531ec8325a5e.tar.bz2
Add ImplItemTypes enum to switch between HIR::ImplItem types
-rw-r--r--gcc/rust/hir/tree/rust-hir-item.h15
-rw-r--r--gcc/rust/hir/tree/rust-hir.h17
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 c5a8d06..0dd7ac8 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 d7977b4..af18d804 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