From 20bf6802ba7b964ec1e570dd4fec971fa3d678f6 Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Sun, 6 Nov 2022 21:21:34 +0100 Subject: ast: Dump raw pointer type Signed-off-by: Jakub Dupak --- gcc/rust/ast/rust-ast-dump.cc | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 273a510..e6d6e07 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 << ']'; } -- cgit v1.1