public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] ast: Dump raw pointer type
@ 2022-11-18 23:33 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-11-18 23:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:20bf6802ba7b964ec1e570dd4fec971fa3d678f6

commit 20bf6802ba7b964ec1e570dd4fec971fa3d678f6
Author: Jakub Dupak <dev@jakubdupak.com>
Date:   Sun Nov 6 21:21:34 2022 +0100

    ast: Dump raw pointer type
    
    Signed-off-by: Jakub Dupak <dev@jakubdupak.com>

Diff:
---
 gcc/rust/ast/rust-ast-dump.cc | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 273a5109846..e6d6e070709 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -1588,12 +1588,36 @@ Dump::visit (NeverType &)
 {}
 
 void
-Dump::visit (RawPointerType &)
-{}
+Dump::visit (RawPointerType &type)
+{
+  // Syntax:
+  //    * ( mut | const ) TypeNoBounds
+
+  if (type.get_pointer_type () == RawPointerType::MUT)
+    stream << "*mut ";
+  else /* RawPointerType::CONST */
+    stream << "*const ";
+
+  visit (type.get_type_pointed_to ());
+}
 
 void
 Dump::visit (ReferenceType &type)
 {
+  // Syntax:
+  //    & Lifetime? mut? TypeNoBounds
+
+  stream << '&';
+
+  if (type.has_lifetime ())
+    {
+      visit (type.get_lifetime ());
+      stream << ' ';
+    }
+
+  if (type.get_has_mut ())
+    stream << "mut ";
+
   visit (type.get_type_referenced ());
 }
 
@@ -1606,7 +1630,7 @@ Dump::visit (ArrayType &type)
   stream << '[';
   visit (type.get_elem_type ());
   stream << "; ";
-  visit(type.get_size_expr());
+  visit (type.get_size_expr ());
   stream << ']';
 }

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

only message in thread, other threads:[~2022-11-18 23:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 23:33 [gcc/devel/rust/master] ast: Dump raw pointer type 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).