public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] ast: dump: add format_{tuple, struct}_field helpers
@ 2022-10-10  7:33 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-10-10  7:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1f9d7ec437307c02427e2977806be656a28c360a

commit 1f9d7ec437307c02427e2977806be656a28c360a
Author: David Faust <david.faust@oracle.com>
Date:   Thu Oct 6 13:43:06 2022 -0700

    ast: dump: add format_{tuple,struct}_field helpers

Diff:
---
 gcc/rust/ast/rust-ast-dump.cc | 17 +++++++++++++++++
 gcc/rust/ast/rust-ast-dump.h  |  6 ++++++
 2 files changed, 23 insertions(+)

diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index b192556647c..6f2f81630b0 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -156,6 +156,23 @@ Dump::emit_generic_params (std::vector<std::unique_ptr<GenericParam>> &params)
   stream << ">";
 }
 
+void
+Dump::format_tuple_field (TupleField &field)
+{
+  // TODO: do we need to emit outer attrs here?
+  emit_visibility (field.get_visibility ());
+  field.get_field_type ()->accept_vis (*this);
+}
+
+void
+Dump::format_struct_field (StructField &field)
+{
+  // TODO: do we need to emit outer attrs here?
+  emit_visibility (field.get_visibility ());
+  stream << field.get_field_name () << ": ";
+  field.get_field_type ()->accept_vis (*this);
+}
+
 void
 Dump::visit (Token &tok)
 {}
diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h
index 1bbefb38454..2da2736c95b 100644
--- a/gcc/rust/ast/rust-ast-dump.h
+++ b/gcc/rust/ast/rust-ast-dump.h
@@ -100,6 +100,12 @@ private:
   // Emit formatted string for generic parameters.
   void emit_generic_params (std::vector<std::unique_ptr<GenericParam>> &params);
 
+  // Format a single field of a tuple.
+  void format_tuple_field (TupleField &field);
+
+  // Format a single field of a struct.
+  void format_struct_field (StructField &field);
+
   // rust-ast.h
   void visit (Token &tok);
   void visit (DelimTokenTree &delim_tok_tree);

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

only message in thread, other threads:[~2022-10-10  7:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10  7:33 [gcc/devel/rust/master] ast: dump: add format_{tuple, struct}_field helpers 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).