public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] ast: Dump InherentImpl Date: Wed, 8 Jun 2022 12:52:26 +0000 (GMT) [thread overview] Message-ID: <20220608125226.A0ADC388B597@sourceware.org> (raw) https://gcc.gnu.org/g:2ad8ec6da7a871debda2e4ce94a63696b7d43422 commit 2ad8ec6da7a871debda2e4ce94a63696b7d43422 Author: Arthur Cohen <arthur.cohen@embecosm.com> Date: Thu Jun 2 16:37:23 2022 +0200 ast: Dump InherentImpl Diff: --- gcc/rust/ast/rust-ast-dump.cc | 83 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 11 deletions(-) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 64966c9d2ec..c23720b59d1 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -102,7 +102,9 @@ Dump::visit (TypePathSegmentFunction &segment) void Dump::visit (TypePath &path) -{} +{ + stream << path.as_string (); +} void Dump::visit (QualifiedPathInExpression &path) @@ -253,8 +255,8 @@ Dump::visit (BlockExpr &expr) if (expr.has_tail_expr ()) expr.get_tail_expr ()->accept_vis (*this); - stream << "\n}\n"; - indentation.increment (); + indentation.decrement (); + stream << "\n" << indentation << "}\n"; } void @@ -364,7 +366,10 @@ Dump::visit (AsyncBlockExpr &expr) // rust-item.h void Dump::visit (TypeParam ¶m) -{} +{ + // Is it possible to have a null type here? + param.get_type ()->accept_vis (*this); +} void Dump::visit (LifetimeWhereClauseItem &item) @@ -376,7 +381,36 @@ Dump::visit (TypeBoundWhereClauseItem &item) void Dump::visit (Method &method) -{} +{ + stream << indentation << "fn " << method.get_method_name () << '('; + + auto &self = method.get_self_param (); + stream << self.as_string (); + + auto ¶ms = method.get_function_params (); + for (auto ¶m : params) + { + stream << ", "; + format_function_param (param); + } + + stream << ") "; + + if (method.has_return_type ()) + { + stream << "-> "; + method.get_return_type ()->accept_vis (*this); + stream << " "; + } + + auto &block = method.get_definition (); + if (!block) + stream << ';'; + else + block->accept_vis (*this); + + stream << '\n'; +} void Dump::visit (Module &module) @@ -405,7 +439,7 @@ Dump::visit (UseDeclaration &use_decl) void Dump::visit (Function &function) { - stream << "fn " << function.get_function_name () << '('; + stream << indentation << "fn " << function.get_function_name () << '('; auto ¶ms = function.get_function_params (); if (params.size () >= 1) @@ -424,6 +458,7 @@ Dump::visit (Function &function) { stream << "-> "; function.get_return_type ()->accept_vis (*this); + stream << " "; } auto &block = function.get_definition (); @@ -501,7 +536,25 @@ Dump::visit (Trait &trait) void Dump::visit (InherentImpl &impl) -{} +{ + stream << "impl "; + + // FIXME: Handle generics + + impl.get_type ()->accept_vis (*this); + + // FIXME: Handle where-clause + // FIXME: Handle inner attributes + + stream << " {\n"; + indentation.increment (); + + for (auto &item : impl.get_impl_items ()) + item->accept_vis (*this); + + indentation.decrement (); + stream << "\n}\n"; +} void Dump::visit (TraitImpl &impl) @@ -728,19 +781,27 @@ Dump::visit (RawPointerType &type) void Dump::visit (ReferenceType &type) -{} +{ + type.get_type_referenced ()->accept_vis (*this); +} void Dump::visit (ArrayType &type) -{} +{ + type.get_elem_type ()->accept_vis (*this); +} void Dump::visit (SliceType &type) -{} +{ + type.get_elem_type ()->accept_vis (*this); +} void Dump::visit (InferredType &type) -{} +{ + stream << "_"; +} void Dump::visit (BareFunctionType &type)
reply other threads:[~2022-06-08 12:52 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220608125226.A0ADC388B597@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).