From patchwork Tue Feb 21 12:01:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 59970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1826976wrn; Tue, 21 Feb 2023 04:13:00 -0800 (PST) X-Google-Smtp-Source: AK7set97lx+vo1rjl/cc5qU7Bb4G3neA9nYnKD3VGIt0fu9mF7aM46pdEjVokyAjzM3zUABUWB6G X-Received: by 2002:a05:6402:18e:b0:49b:7416:e3ff with SMTP id r14-20020a056402018e00b0049b7416e3ffmr3038709edv.5.1676981580768; Tue, 21 Feb 2023 04:13:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676981580; cv=none; d=google.com; s=arc-20160816; b=v74KNfvGPRC5B+PRVPfz0CgbIARFFOPlSV+mIDoLt6qXvjQ9OxDJx4nWeYsmFa3biA ZjLxEwrOpPuSDCMkUnvDYaSG8di2rfyW10gXzB2lzOkNkv3iKKMpayy8c/jKrGupFJtY aWA7l5h/U8o4MXaFW9CWsVxbK8CyrvGrcA1PadCUGVt3gLfMSzeSvNGq0kZK4oMYRJnK rkXQ5sVSw0aSrPC/7b31WnHozEcv4540SdkjOU55uYwkDoXcGK+w9y8ikU7mJS5MKH1y kZjjvJpTSSFNOZ6huZuqjWHvDF5cG5B23uLDMQpmpGBSRVozFDu0rvr4+qZpYJ1AddSP 0U9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dmarc-filter :delivered-to; bh=tJwh/YmAJ2py2ku/xMA2IypoS6a5fFPBtjWDiCL6jqA=; b=UDjByQw2I+JrGbkfuu84Vbj4zrq9+3uTAOidM6UBunTHmlRVM5eRWugZTWKhlkoKMQ QZTOx6nXLnszc6Fje68uoQublw7IVkDr4S+hP8IYZWGnFq6MtqflFUNcx6UFyXUmr7yE rfQ/DHkV0NLjST6ED2GgF58Dc998/zKD3xVVC/+spDE3lvXEIlEU0hKsq/lj2wT/qM+4 p+jWqEuN1kFgzEY/tsJ899VChBHXOfuX6FlaRREkagXvf6zwRAMqw3r2vKhl3L5DUQ+A UNcyNdOX+TDZ3xvp2Tf18EbGaTX0AjEOkca71zfvnDiTo33jCNhMbRWH/EB10/i0R7Yd kAVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embecosm.com header.s=google header.b="bOYiDb/+"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p8-20020aa7d308000000b004acc183f530si929520edq.229.2023.02.21.04.13.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:13:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@embecosm.com header.s=google header.b="bOYiDb/+"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9AE663954C6D for ; Tue, 21 Feb 2023 12:06:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 854D838493F8 for ; Tue, 21 Feb 2023 12:03:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 854D838493F8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x42e.google.com with SMTP id o4so4163460wrs.4 for ; Tue, 21 Feb 2023 04:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=tJwh/YmAJ2py2ku/xMA2IypoS6a5fFPBtjWDiCL6jqA=; b=bOYiDb/+tt7Um9tX49L7IGLB7hCkKyWvmjdot6mTU8naCZvVUsRNRT+tGdnoB1Mfnz f2SNEY88E6IGY2G7FG/za0sRgcJPZ+6rDK+EeRuwcMPycijw1H+zaMaAvdoCYheMTe2h TPxuQClX0pX4eaBKsfQypilV9lAsceBcVhMtlk1pDQ1I+bjZ+jq+4AgTOzZSNE+UYHLJ EZnQBWnVWp0g7olBbEWMTsPmk0DefatYFpt2kKdhRB3fQKMvLm2IxPMCcedqfSkv55WH 1br3mNIm15U6aQlBhhyO1NWt3RY77BM48nuwiIWGxVTqGC/4ZWhpGAngal7WlrztBd6+ FkHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tJwh/YmAJ2py2ku/xMA2IypoS6a5fFPBtjWDiCL6jqA=; b=MSAUdV+p3J05S4Z69XfwYbfaYYGYq4pNWUDQ5QFbtXuoxF3KMZINRwcM79+An6zDos dvasqn9proxjh+YSBxSeAwNbJyhRwTU7VofwKqnJ/JJGcPjDdSTKTN2A7oVYE470QifI oOVMzNBUUG4SX9W8+SLOEypUQ32/Q21ZOSsmVVf2QMclKS/neP64wwAcMm8H7wBvts+t BVmcVp/aNyGwUjHtFyjJ4X9xT2KScWsGHRi72zvOuHEMzO72lJYCVJSHp2vbG11b9Avv MfdsszYLgo8BJ0fCTuOx35bj3H5JapGlRtAnINkhtHk17yO8cBboeAsGHbl+9Gz+0yQ8 BjPg== X-Gm-Message-State: AO0yUKV8Y2tyvDDOoNin8+y4iu35pvL5Tn8wfwk6OVXTcYAjuzlvuVGF kb+BRLSQIm3JRAs3awDMX/NZg7mnVd79pBwTcw== X-Received: by 2002:adf:e9c7:0:b0:2c5:7c26:c2cc with SMTP id l7-20020adfe9c7000000b002c57c26c2ccmr3926694wrn.29.1676981014144; Tue, 21 Feb 2023 04:03:34 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:03:33 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, David Faust Subject: [committed 013/103] gccrs: ast: dump: add format_{tuple, struct}_field helpers Date: Tue, 21 Feb 2023 13:01:03 +0100 Message-Id: <20230221120230.596966-14-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758442637985767229?= X-GMAIL-MSGID: =?utf-8?q?1758442637985767229?= From: David Faust gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::format_tuple_field): New. (Dump::format_struct_field): New. * ast/rust-ast-dump.h (format_tuple_field): New. (format_struct_field): New. --- 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> ¶ms) 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> ¶ms); + // 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);