From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id 03B273858426; Tue, 21 Feb 2023 11:58:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 03B273858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676980702; bh=aYTKa2NorId69U2dcHes96IX3BXM/8XdsWIdp1ff80c=; h=From:To:Subject:Date:From; b=X4Pb2PAWEoibY4ZiSDaRD6g15m0ZY4EBbm6ilc+/G0O66sXh4Xgqp/lEJHP296rmW HDNuaKJJlwmA7xvTZJ81CEPcHSgoja+XuHirE2u8foY6dHnusyncKNWXpeMQ0f12zQ l23IKyv070aFRGcJMEnn93lRxdrU4TYu6wX7PbMk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6190] gccrs: ast: Module: unloaded module and inner attributes X-Act-Checkin: gcc X-Git-Author: Jakub Dupak X-Git-Refname: refs/heads/master X-Git-Oldrev: 2f16df1b443329694d1daf3e02987841a0857ede X-Git-Newrev: e535b7b3e385edbc4cb830328f11fa5492df5d77 Message-Id: <20230221115822.03B273858426@sourceware.org> Date: Tue, 21 Feb 2023 11:58:22 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e535b7b3e385edbc4cb830328f11fa5492df5d77 commit r13-6190-ge535b7b3e385edbc4cb830328f11fa5492df5d77 Author: Jakub Dupak Date: Sat Oct 15 21:30:40 2022 +0200 gccrs: ast: Module: unloaded module and inner attributes gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Properly handle unloaded modules. 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