From patchwork Tue Feb 21 12:01:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 60032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1839409wrn; Tue, 21 Feb 2023 04:43:05 -0800 (PST) X-Google-Smtp-Source: AK7set/HoL3JEUFGbt9Txdfc0D7AkJM9eEShsnwx9R2ywKn64JQeqBo9TgEEbjcUwdM536GFwbfa X-Received: by 2002:a17:907:888b:b0:878:6519:c740 with SMTP id rp11-20020a170907888b00b008786519c740mr16111610ejc.44.1676983385652; Tue, 21 Feb 2023 04:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676983385; cv=none; d=google.com; s=arc-20160816; b=z1YDO7wccrbBTjS6xfj9vaIwhWk4nyzuj+C2pdWaG6nL3qfulJ4Y0lbh3JN3sdQv3K k+bRs4AE3s7FJ+8BUQsqtwmPVgRJtHGIvfFSqfRA1NTI/9zjloQLOuojArQCk5inImDa HXmsE9L0Qortv9ksr1HM6y6QoJ5Ge37aJMnOOzCk8hXNztQqp+vRAP8QNLJwk5ME+8D2 S57ljsxcBNTPHPW1+bJqvpOfzQDx1s4aUMZJ3j8FBmgpC3eU5+qR+I2wFz89C+08yBiA NAZ8hVBspkmyXl7c1RYnk2AWaXn+1geqpgv4DpI3olUtavQ5/I/0U24MGLVhZrLZqdKx cXqQ== 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=W1xmgehrU8TuQqqCih7THK1rfPPB+3RmditxusaMbCs=; b=gsZi8TtniGz66w1/h5E++8wf/HFS4wZoIq4OUGy4lICW0Wing1VZwfcTec/Hwk5KH2 6pwJLl1532WHdPsrwe3Ci73k8EAG67j4JWWAVjcByE5CQCDTThMscPtCw8Ay8OBg7S11 oyKxeKt5dSZLYcfDJ0zBGobJja6+TrxGOofziBaxgcYs7Xh70DhQoUVOPUjkJe8ESEqo tvLj82i6EffcT0FuujhzBu0TLIY0o5255pcll+/1+m6capfmtmaSpvvB5YxsNIWFrnwB oPgE99nfV3WS8AauykJSXAWrVLU2k33bz8PiizbcnY9sAxM7ouUjPDSpvlm5vqXYcAeJ W3Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=KMOLu21R; 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 zz14-20020a170907350e00b008da033ef977si4071882ejb.731.2023.02.21.04.43.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:43:05 -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=pass header.i=@embecosm.com header.s=google header.b=KMOLu21R; 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 B5E32383FE1B for ; Tue, 21 Feb 2023 12:14:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id B9DF738323E6 for ; Tue, 21 Feb 2023 12:04:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9DF738323E6 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-x42c.google.com with SMTP id r7so3992592wrz.6 for ; Tue, 21 Feb 2023 04:04:16 -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=W1xmgehrU8TuQqqCih7THK1rfPPB+3RmditxusaMbCs=; b=KMOLu21R3rCTRHso2OiTEYDNNI9KWq0+DvGRV8QXFSzNzK1PSQigRUeCmCX2FHtmTz hG60IPBn1xVPdWJiFlkFn7dweWMhGNlAkJNWAbYe+iV3LYMgJY2575ZPgSwTXWAU0hMd b1cAl2A4GNiz0W46rbk9clR99yb9R58LeWu24TzzWquYpUiUf3/eq3GeAz/g/qJlop47 Mjvaqt8IxxTLCubkk2G++VgTtImCPsgnFVKQy+h888EOTKfeUNq87Mvqzx1vsx1QzDH9 eAoCWBEZmNzUtl9ZTQ229rSv4xRojx3F565PjC39CKgfheRu7H6lEcJOnstQgYJkpmO3 UAsw== 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=W1xmgehrU8TuQqqCih7THK1rfPPB+3RmditxusaMbCs=; b=DITJWV+WcVjerDMEQdTOrXVaZ6MC7wHLQ/Q/l5HIr1qgWHQQ1/7j46BFrq9kCKu9CU N8ACdYC8gmFwYjQz5W7qaKtBw1oBLPrCPTcRrPoHb7w+s2CCUAX5S/cNhmrLPDJEDVko +LBTP8SIZcPIHk+6OHggb3cEVL4pt9gnZF+X7Sg4mgLpGxP8TqmttQRRw+cIca+w6jTV 6C61k1Qt56taRj7zSkpZbgc55Tf9mz340F11oWPLkSSQCp3Z/5ValR+1mB8WqhzvysIX lTI2f8vJsFKFNLiygG7EoTXqoq98dHLYfdfWQaXzeI6dRMNjOumuo4lGaEzmxG/tOgdM O5Dw== X-Gm-Message-State: AO0yUKXuMdMo9zz3ycLUCIptid3Yfh50H6g6ZxrZI5hDIszBRbr8Biln bTXM/WXS+0L4OXZGWiSyE0eldOVNN/Ozbxodpg== X-Received: by 2002:a05:6000:114e:b0:2c4:9d7:c7da with SMTP id d14-20020a056000114e00b002c409d7c7damr3305029wrx.65.1676981055849; Tue, 21 Feb 2023 04:04:15 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:15 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak Subject: [committed 065/103] gccrs: ast: visitor pattern -> overload syntax compatibility layer Date: Tue, 21 Feb 2023 13:01:55 +0100 Message-Id: <20230221120230.596966-66-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.3 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?1758444531013473088?= X-GMAIL-MSGID: =?utf-8?q?1758444531013473088?= From: Jakub Dupak gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add new visit function for overloading. * ast/rust-ast-dump.h: Add documentation for layer. Signed-off-by: Jakub Dupak --- gcc/rust/ast/rust-ast-dump.cc | 7 +++++++ gcc/rust/ast/rust-ast-dump.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 4817962f767..9771f432ea0 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -62,6 +62,13 @@ Dump::go (AST::Item &item) item.accept_vis (*this); } +template +void +Dump::visit (std::unique_ptr &node) +{ + node->accept_vis (*this); +} + void Dump::format_function_param (FunctionParam ¶m) { diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h index 9fe8ee95493..7cd922e0ac9 100644 --- a/gcc/rust/ast/rust-ast-dump.h +++ b/gcc/rust/ast/rust-ast-dump.h @@ -72,6 +72,14 @@ private: std::ostream &stream; Indent indentation; + /** + * Compatibility layer for using the visitor pattern on polymorphic classes + * with a unified overload syntax. This allows us to call `visit` both on + * types implementing `accept_vis` method and for classes for which the + * `visit` method is directly implemented. + */ + template void visit (std::unique_ptr &node); + /** * Format together common items of functions: Parameters, return type, block */