From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id AE4F03858286; Mon, 17 Oct 2022 12:34:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AE4F03858286 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666010060; bh=F/vES7z+DZAssgAjaclc+4RPBNmmVY1Wk0E7Vpwjivw=; h=From:To:Subject:Date:From; b=pz0x0Ng1V8+iCyS3CvCvlDj4sWCDJ95QcALBO2b7fUCS7jO2JHLNLI1FED3jBK0DA C+mgSmH8NGWt0pg0Db4g49W8yVT1yu6JEyvBlNbr192syoKX7RT6DmgCGowaP5iCLC j6MNeiDneDkSx1UcryEvfdWo7gFONFJXERzPkQdY= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] ast: Module: unloaded module and inner attributes X-Act-Checkin: gcc X-Git-Author: Jakub Dupak X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 3922772f5f2e5ab245342defca6b53e1563de881 X-Git-Newrev: b2add3214565a70403402e80e11352f8a1e3681a Message-Id: <20221017123420.AE4F03858286@sourceware.org> Date: Mon, 17 Oct 2022 12:34:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b2add3214565a70403402e80e11352f8a1e3681a commit b2add3214565a70403402e80e11352f8a1e3681a Author: Jakub Dupak Date: Sat Oct 15 21:30:40 2022 +0200 ast: Module: unloaded module and inner attributes Signed-off-by: Jakub Dupak Diff: --- gcc/rust/ast/rust-ast-dump.cc | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 1e7a235932d..a12c3922c47 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -810,21 +810,44 @@ Dump::visit (Method &method) void Dump::visit (Module &module) { - emit_visibility (module.get_visibility ()); - stream << "mod " << module.get_name () << " {\n"; + // Syntax: + // mod IDENTIFIER ; + // | mod IDENTIFIER { + // InnerAttribute* + // Item* + // } - indentation.increment (); + emit_visibility (module.get_visibility ()); + stream << "mod " << module.get_name (); - for (auto &item : module.get_items ()) + if (module.get_kind () == Module::UNLOADED) { - stream << indentation; - item->accept_vis (*this); - stream << '\n'; + stream << ";\n"; } + else /* Module::LOADED */ + { + stream << " {\n"; - indentation.decrement (); + indentation.increment (); - stream << indentation << "}\n"; + for (auto &item : module.get_inner_attrs ()) + { + stream << indentation; + emit_attrib (item); + stream << '\n'; + } + + for (auto &item : module.get_items ()) + { + stream << indentation; + item->accept_vis (*this); + stream << '\n'; + } + + indentation.decrement (); + + stream << indentation << "}\n"; + } } void