From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 5EFAE38493EE for ; Tue, 21 Feb 2023 12:03:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5EFAE38493EE 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-x435.google.com with SMTP id t13so4088077wrv.13 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=BBC7MfBO40k5gnzI6xuoezjV4pRWBG/Q9tas75nh0jjxCWkL+EJF1dNT8vhBBshBuZ f35EESEfWQaEb4WM+Q6FR1DgUMVuVBCeq565xO1NVpHx61BNDk6zWjidK8ezVTEBb0Ea h/hxtEb6aIcudiD8s0PBT1gwkcWkI910MADJ5NgR68k0kwzqSDpZqCYTVpODhUi3AFap 7oLZLedsNxSl4+pKQN1/F11I+FwHyhvOFQvY9pBA135etutnSYZEtjTrNF+XV+1OfLRO w9Q4FrC/NOPCWAzzk8GKe8md50mZ2ZtMO29O5JfQw8GxhQcRlUkClSr243DFYZroyaqW wQqg== X-Gm-Message-State: AO0yUKXcIMSWq4ddce3mNmcpmvYsD9HhmeuvauxwJwnqRaBI2XWxxq+7 YUIIEffdVX/AIKJDghQngmaG X-Google-Smtp-Source: AK7set9Hy3c9KDv7nym/Ee6U6tzGG55rziEtRUxxH6WL9sZ6cjPilWZmmqS4AIt/mO7VB9F3J37D0g== 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> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.4 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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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); -- 2.39.1