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

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

commit cf94fd8d51fcbf5f857a26dc7ae09e29384abc95
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Mon Mar 28 10:33:25 2022 +0200

    single_ast_node: Add TYPE kind

Diff:
---
 gcc/rust/ast/rust-ast.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index a22c2d1ad1d..5368c427b42 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1515,6 +1515,7 @@ public:
     TRAIT,
     IMPL,
     TRAIT_IMPL,
+    TYPE,
   };
 
 private:
@@ -1528,6 +1529,7 @@ private:
   std::unique_ptr<TraitItem> trait_item;
   std::unique_ptr<InherentImplItem> impl_item;
   std::unique_ptr<TraitImplItem> trait_impl_item;
+  std::unique_ptr<Type> type;
 
 public:
   SingleASTNode (std::unique_ptr<Expr> expr)
@@ -1558,6 +1560,10 @@ public:
     : kind (TRAIT_IMPL), trait_impl_item (std::move (trait_impl_item))
   {}
 
+  SingleASTNode (std::unique_ptr<Type> type)
+    : kind (TYPE), type (std::move (type))
+  {}
+
   SingleASTNode (SingleASTNode const &other)
   {
     kind = other.kind;
@@ -1590,6 +1596,10 @@ public:
       case TRAIT_IMPL:
 	trait_impl_item = other.trait_impl_item->clone_trait_impl_item ();
 	break;
+
+      case TYPE:
+	type = other.type->clone_type ();
+	break;
       }
   }
 
@@ -1625,6 +1635,10 @@ public:
       case TRAIT_IMPL:
 	trait_impl_item = other.trait_impl_item->clone_trait_impl_item ();
 	break;
+
+      case TYPE:
+	type = other.type->clone_type ();
+	break;
       }
     return *this;
   }
@@ -1699,6 +1713,12 @@ public:
     return std::move (trait_impl_item);
   }
 
+  std::unique_ptr<Type> take_type ()
+  {
+    rust_assert (!is_error ());
+    return std::move (type);
+  }
+
   void accept_vis (ASTVisitor &vis)
   {
     switch (kind)
@@ -1730,6 +1750,10 @@ public:
       case TRAIT_IMPL:
 	trait_impl_item->accept_vis (vis);
 	break;
+
+      case TYPE:
+	type->accept_vis (vis);
+	break;
       }
   }
 
@@ -1751,6 +1775,8 @@ public:
 	return impl_item == nullptr;
       case TRAIT_IMPL:
 	return trait_impl_item == nullptr;
+      case TYPE:
+	return type == nullptr;
       }
 
     gcc_unreachable ();
@@ -1775,6 +1801,8 @@ public:
 	return "Impl Item: " + impl_item->as_string ();
       case TRAIT_IMPL:
 	return "Trait Impl Item: " + impl_item->as_string ();
+      case TYPE:
+	return "Type: " + type->as_string ();
       }
 
     gcc_unreachable ();


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

only message in thread, other threads:[~2022-06-08 12:25 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:25 [gcc/devel/rust/master] single_ast_node: Add TYPE kind 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).