From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id 33E993858018 for ; Tue, 30 Jan 2024 12:11:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33E993858018 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33E993858018 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::230 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616664; cv=none; b=rWxilQ4iYBf+7NcYf2PY5ALou6ry0JOKODfc4ddlz+esV2PAsR3txcq3EncecjW5RIRP5gnIvqy3I2BfzeVJA4YUYwaeEiVN+SH4xSAFZ5UCl+hl2BQdavBR0nq9Icbc54twDNMBp1tw/hQIB+/LbzlgZP5oSKmISMrPTJcOIg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616664; c=relaxed/simple; bh=u0LufJgOETfsbbkuJgKzJVFxRbyQmbFFz0nirPTbPoc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YO5j3+UZtn1ckitZg5dx/dUDz0EhT7kjHCYOKI84WoycfEaiN2PxWe9721eg9kYld2Yx2Xu1xrToxtVsYiYq56qT0OqNQkn5nXgFxecJpd1bh6YjHTMWt+NwP3IRIascnx1fbmEvjT/82TMSiSWjWsI4GVsgBheoespaUwX15Qg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2cf45305403so37537091fa.2 for ; Tue, 30 Jan 2024 04:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616660; x=1707221460; darn=gcc.gnu.org; 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=AAA+tUrpjHaW4zs1uyJOfNzO47oHzJEHDWM2+KLxQRQ=; b=PHEB+hraSZXqGyLlHU+2CoCZO1kf9vs1F2/CclLpsnjpxlkIqkFHz4FZAqtvNbNri0 xio1FqubPBPBPmCuLel34i9qNVZbEIVbbquefBSTwXy3O76D82uFHKY6LuX5MDprvUCb kvSRUIakT8xQC8t6m4k7Nt8KPUCSRR9cYCn7eOp3IWDk3vQKbWMgHGml+5z+kVL8/yIA taCh92V2cABGjP++2lcPSf0Go3HR7eG1PqcO2WEwis5PDQxFHYW9Bs+oLgHo8yJSnekU +szQTsgLNehSdrtz+MQjxKQdMayKNXjV8F023tour+Qjdn/LP+wv2JZ1J32fo+72NaNs QjjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616660; x=1707221460; 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=AAA+tUrpjHaW4zs1uyJOfNzO47oHzJEHDWM2+KLxQRQ=; b=JOAoKboH0fjIx6Uf9/gMwK+d0eFJcaXAGHmOH0dg0vogKSxhMMYfg6ELAOr7xwlazy uYK15OoGkdLnqULO7q3VyZesFWFIkjzAJpLuTKfoLfzYnpn+E+yshPoOWh7YGa14cP0B L9cahm+tNyuWx1Z7dRZGQCX+lWGOjpdcmQ6DYURAy8oX8u8rp+wLkiXfnw1Nv08i0dJZ dGCj3nCZZER2Gr/kQ+ovyAWClXM/eDneedn4jR76yDGeAfvP/FJV4DIQmzzAY7yC5+CC 57jbRQgnFvbADykeAO3/3KVzvDNAzoVXHmQ8OoBw1lcv5zEKSRrLGv29VIaBQrbA/87l FTbA== X-Gm-Message-State: AOJu0YyHw9wqWUXigSY5HazMswf8zppvpZAWpYC3sUkfkPE3NNLP4XWN gyPscMr++6CrgvDgpWsHqKYPJvKQm6qPdR9FvbeGsDk9noNMrJzX03y44296SN+JGPJGFou81af V7Q== X-Google-Smtp-Source: AGHT+IEr11s/OYDdsCfqG2XQjmF112lXWWETf90fxoJETLhXgRGP7s8dlI8jUpnaydG/9SOzhZizXg== X-Received: by 2002:a2e:b8c4:0:b0:2cd:3b6:b3d7 with SMTP id s4-20020a2eb8c4000000b002cd03b6b3d7mr6308444ljp.34.1706616659853; Tue, 30 Jan 2024 04:10:59 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:10:58 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [COMMITTED 013/101] gccrs: foreverstack: Add `to_rib` method Date: Tue, 30 Jan 2024 13:06:29 +0100 Message-ID: <20240130121026.807464-16-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.1 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,T_SCC_BODY_TEXT_LINE 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: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: New method. * resolve/rust-forever-stack.hxx: Likewise. --- gcc/rust/resolve/rust-forever-stack.h | 2 ++ gcc/rust/resolve/rust-forever-stack.hxx | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h index 37277ddb3ad..a540e682e5b 100644 --- a/gcc/rust/resolve/rust-forever-stack.h +++ b/gcc/rust/resolve/rust-forever-stack.h @@ -585,6 +585,8 @@ private: // FIXME: Documentation tl::optional> dfs (Node &starting_point, NodeId to_find); + // FIXME: Documentation + tl::optional dfs_rib (Node &starting_point, NodeId to_find); }; } // namespace Resolver2_0 diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 4e06da235bf..65796172b08 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -532,11 +532,29 @@ ForeverStack::to_canonical_path (NodeId id) template tl::optional -ForeverStack::to_rib (NodeId rib_id) +ForeverStack::dfs_rib (ForeverStack::Node &starting_point, NodeId to_find) { + if (starting_point.id == to_find) + return starting_point.rib; + + for (auto &child : starting_point.children) + { + auto candidate = dfs_rib (child.second, to_find); + + if (candidate.has_value ()) + return candidate; + } + return tl::nullopt; } +template +tl::optional +ForeverStack::to_rib (NodeId rib_id) +{ + return dfs_rib (root, rib_id); +} + template void ForeverStack::stream_rib (std::stringstream &stream, const Rib &rib, -- 2.42.1