From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 40DA9381ECB6; Wed, 8 Jun 2022 12:40:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40DA9381ECB6 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] ast: resolve: Add SimplePathSeg -> CanonicalPath resolver X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 0b91defe9422d1f0931b46beff4d22e7b4e37fd8 X-Git-Newrev: 821c7947bfd6787fdaaba8dca2f9468661666dcc Message-Id: <20220608124020.40DA9381ECB6@sourceware.org> Date: Wed, 8 Jun 2022 12:40:20 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 12:40:20 -0000 https://gcc.gnu.org/g:821c7947bfd6787fdaaba8dca2f9468661666dcc commit 821c7947bfd6787fdaaba8dca2f9468661666dcc Author: Arthur Cohen Date: Tue Apr 26 10:03:41 2022 +0200 ast: resolve: Add SimplePathSeg -> CanonicalPath resolver Diff: --- gcc/rust/ast/rust-ast.h | 1 + gcc/rust/resolve/rust-ast-resolve-path.h | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 666fd7cb00f..fb8982a780f 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -349,6 +349,7 @@ public: Location get_locus () const { return locus; } NodeId get_node_id () const { return node_id; } + const std::string &get_segment_name () const { return segment_name; } // TODO: visitor pattern? }; diff --git a/gcc/rust/resolve/rust-ast-resolve-path.h b/gcc/rust/resolve/rust-ast-resolve-path.h index 7a4413b8ca1..60793d331ab 100644 --- a/gcc/rust/resolve/rust-ast-resolve-path.h +++ b/gcc/rust/resolve/rust-ast-resolve-path.h @@ -37,12 +37,23 @@ private: void resolve_path (AST::PathInExpression *expr); void resolve_path (AST::QualifiedPathInExpression *expr); + void resolve_path (AST::SimplePath *expr); void resolve_segments (CanonicalPath prefix, size_t offs, std::vector &segs, NodeId expr_node_id, Location expr_locus); }; +class ResolveSimplePathSegmentToCanonicalPath +{ +public: + static CanonicalPath resolve (AST::SimplePathSegment &seg) + { + // FIXME: Since this is so simple, maybe it can simply be a tiny function? + return CanonicalPath::new_seg (seg.get_node_id (), seg.get_segment_name ()); + } +}; + } // namespace Resolver } // namespace Rust