From patchwork Tue Feb 21 12:01:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 59980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1829894wrn; Tue, 21 Feb 2023 04:20:00 -0800 (PST) X-Google-Smtp-Source: AK7set8SLVObr9jfG8PPzCFJ/LGKdqa528fr3gnm+/ZWjd4ISdFW7JkWXiPz2cMHLEkM+OH+MvrY X-Received: by 2002:a05:6402:755:b0:4ad:6ca7:6134 with SMTP id p21-20020a056402075500b004ad6ca76134mr5376869edy.30.1676982000506; Tue, 21 Feb 2023 04:20:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676982000; cv=none; d=google.com; s=arc-20160816; b=LIrtf9hLYu3V3rE/DH5YdYs+SPeyUf5N9KtwdeuFEnBg3ywmtxz3RhDN7c5M88BWvP RRb3fOONnf+RrYO16m7j9o/yMmDFEdB69spE/N5Rn7GCrRf2ibnm7RxStGlBb1alY4Hu ziCOwRwFTfXC1r04+psHNEyhoVBb6PWTKeQoEp2MxzH4rSIsWAaSxumynvSi7Di5saVh 1BdfqTT8xfC3yWfZqPV0I1rcsY1du/VNDNShnECkvGU/rIDlnGPuFv6Sm2SKtm//T1CV dNz3lkhDIPpH/JYS6krRFo9G/JNsFYg1EwUg7ALXouv6o/eICDD5AesVOfhkS0PXowAU 6WlA== 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=T0DYbXI1IPQ+wNckeL/Ao7Wjwpi9gOtXH9sqjOHGUWo=; b=vocWjdb4Gg/iHG10hZaDEm/kLZlkJaDbID77V/WTWvnwfBWyzoH225aksdnVTDEZO5 +kkasB0VlF45FWAixGuhbxuCMBHq+Q+UBVW0R9XjyhDr6IPbAy7oRF9Dw+KwZTsxrbPA HhIXzqroQBAV+rlKO8Y3q+QW1il8FxS1GyxNQRuEvMseDA8QRp1ruAzMkJyB0XUulQrf qaIMI64b+szz+a77U1tqKWBZgzKYpphGQ7QWyTMOIH2ar28mhQJtdHM774NN17tWi+XH 2TnZ9OQXDfvbYrR+jkkygKXed2NeQBFkKDCzE1PUsHlg7KtSJzObC6AmbES9DiC0jZ65 9CvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=AAsUsO16; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o2-20020a056402038200b004ad79746598si6953386edv.173.2023.02.21.04.20.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:20:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=AAsUsO16; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 9DEA238362D6 for ; Tue, 21 Feb 2023 12:08:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 163873843883 for ; Tue, 21 Feb 2023 12:03:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 163873843883 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-x431.google.com with SMTP id z8so3883102wrm.8 for ; Tue, 21 Feb 2023 04:03:48 -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=T0DYbXI1IPQ+wNckeL/Ao7Wjwpi9gOtXH9sqjOHGUWo=; b=AAsUsO16x2hAFtpTum+N4L9DbWJ6TSqrTcQjXN+rk1r9stTSbfv4HdXmyr/yU3JtoQ J5+WIzVHT3/Cbbu7EpNGPIIOCJcCwrV6vjo8tzwQIUoMey5XHhSPUMlwXXowNnHZ9zAN aQ+qOlG6/Of10j+8pRqbutLzzox/UTrDIX+R57sgC/F6TcpmVeSdVTn4LRdxohQuSBnO yWGRCtUnqRhCM7C96bfNQtRAqc7MbzEq4N91TLYaXimIWjeKsoaEGfkXv4X4KwZpFbkZ apSF98MpsrTKFFb0uGBEO34FmhSye8tK6k7iAIIR7AySvYqRoWRBaI64k1CuW/htPQwe 0CTg== 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=T0DYbXI1IPQ+wNckeL/Ao7Wjwpi9gOtXH9sqjOHGUWo=; b=O5/rpH7stXXbeFFhsFs+UX7Iabv77wSB8wFkrbg/h3AorrV0VVb7Z1bEc82fJncqk4 PfkYBa0scbqdekofLjtPhPcxpLAiP0/Ec/juj6k7wnrL/8BpGa2uEsqXUf1sQemKeMLL 9xSVjNHjtf/P4sQmDEl8IHnHlNYsZSSAAHnOiC7yWeSSgevnS1HBqCsAhTmdTgHzR9MJ 4VB6yFMu0d4z+yNz7cAwDCgwdPtuifr4kHIDfUcV3ZxX2UAgJKqhgZE9WUKE3axEPd45 CPwVdGkzF4LsOdg4a+BU0BKZ91+VvJNePkG8mS/FftU9y2KF/FYYRp80ws4VB3n06CY2 BnQQ== X-Gm-Message-State: AO0yUKWCe+245hcS8LnprEyYM4Hxs0BfPjJAWH+8yYtfGiTQRdzj5n5p jrMWCn2u8AEHEEVurPCZWgl9q2dE3X9fF94xPg== X-Received: by 2002:a05:6000:1c5:b0:2c5:61ef:7b36 with SMTP id t5-20020a05600001c500b002c561ef7b36mr4502501wrx.67.1676981026721; Tue, 21 Feb 2023 04:03:46 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:03:46 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, David Faust Subject: [committed 029/103] gccrs: ast: dump: various simple Exprs Date: Tue, 21 Feb 2023 13:01:19 +0100 Message-Id: <20230221120230.596966-30-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=-15.0 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 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?1758443078269415822?= X-GMAIL-MSGID: =?utf-8?q?1758443078269415822?= From: David Faust Adds dump for: - BorrowExpr - DereferenceExpr - ErrorPropagationExpr - NegationExpr - TypeCastExpr - GroupedExpr gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add dump for, BorrowExpr, DereferenceExpr, ErrorPropagationExpr, NegationExpr, TypeCastExpr and GroupedExpr. --- gcc/rust/ast/rust-ast-dump.cc | 45 ++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 91e540a1ee8..b9e08b59554 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -259,19 +259,44 @@ Dump::visit (MetaItemPathLit &meta_item) void Dump::visit (BorrowExpr &expr) -{} +{ + stream << '&'; + if (expr.get_is_double_borrow ()) + stream << '&'; + if (expr.get_is_mut ()) + stream << "mut "; + + expr.get_borrowed_expr ()->accept_vis (*this); +} void Dump::visit (DereferenceExpr &expr) -{} +{ + stream << '*'; + expr.get_dereferenced_expr ()->accept_vis (*this); +} void Dump::visit (ErrorPropagationExpr &expr) -{} +{ + expr.get_propagating_expr ()->accept_vis (*this); + stream << '?'; +} void Dump::visit (NegationExpr &expr) -{} +{ + switch (expr.get_expr_type ()) + { + case NegationOperator::NEGATE: + stream << '-'; + break; + case NegationOperator::NOT: + stream << '!'; + break; + } + expr.get_negated_expr ()->accept_vis (*this); +} void Dump::visit (ArithmeticOrLogicalExpr &expr) @@ -381,7 +406,11 @@ Dump::visit (LazyBooleanExpr &expr) void Dump::visit (TypeCastExpr &expr) -{} +{ + expr.get_casted_expr ()->accept_vis (*this); + stream << " as "; + expr.get_type_to_cast_to ()->accept_vis (*this); +} void Dump::visit (AssignmentExpr &expr) @@ -445,7 +474,11 @@ Dump::visit (CompoundAssignmentExpr &expr) void Dump::visit (GroupedExpr &expr) -{} +{ + stream << '('; + expr.get_expr_in_parens ()->accept_vis (*this); + stream << ')'; +} void Dump::visit (ArrayElemsValues &elems)