From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 4D3A538323C3 for ; Tue, 21 Feb 2023 12:04:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D3A538323C3 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 l25so3759341wrb.3 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=T/jEGfw64QJCJ3eR1Tw8M4HQ8njmRL0uaXmXiksAFHIXtkiaLkvd1Bh7ia5WmLnyg4 TK0nNVLW/900AmoEbQilDE/LNIql/nGCFrSAZx93G1Mvb7FEYfmr2/UTvLSOu+qR69y8 bq95C9oFEJDgvZxdBATakNEOM/z4AT/IERD0dZAXCsaTPGKrsxYW4Ip1G33QJTSOgsBr hpG68ImM4X7y0GxCTIKEk9BPU48QOqoFoqjdv7z2UM4o3FdTga+DEDGbUWxOyfDSqC4x wGrNIkNg5Bq7Ni2MsJXRfBigrfG6VFDGxin4Zh7olIZqmGHCE+w9GBI7X5SL+0Cz3y7L T1iA== X-Gm-Message-State: AO0yUKWxOaVXORS/Ppn7yMMxiARZju02LC1Woyo48tMUI9khN2IctoqN VFt6W/2W8pM/6CR7kqHOYTY1l3V12/DRvCVotw== X-Google-Smtp-Source: AK7set92SmZhu/Y1Kuby5Ad89gzNqf1qZjWZqWxPCT7p14k3UkM0PP8uowIUQo38StQQXAm4pc76+w== 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> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.8 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 List-Id: 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 */ -- 2.39.1