public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8562] gccrs: late: Start storing mappings properly in the resolver Date: Tue, 30 Jan 2024 12:00:01 +0000 (GMT) [thread overview] Message-ID: <20240130120001.D75FA3858420@sourceware.org> (raw) https://gcc.gnu.org/g:0f0ec052b4ad1fb7250a5ad1ec00d276fdc29a09 commit r14-8562-g0f0ec052b4ad1fb7250a5ad1ec00d276fdc29a09 Author: Arthur Cohen <arthur.cohen@embecosm.com> Date: Tue Aug 22 17:29:05 2023 +0200 gccrs: late: Start storing mappings properly in the resolver gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Store mappings after having resolved them. * resolve/rust-late-name-resolver-2.0.h: Add `TypePath` visitor. Diff: --- gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 33 +++++++++++++++++++++---- gcc/rust/resolve/rust-late-name-resolver-2.0.h | 1 + 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc index 3236886f37d4..5f70f5755824 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc @@ -20,6 +20,7 @@ #include "rust-ast-full.h" #include "rust-late-name-resolver-2.0.h" #include "rust-default-resolver.h" +#include "rust-path.h" #include "rust-tyty.h" #include "rust-hir-type-check.h" @@ -121,11 +122,24 @@ Late::visit (AST::IdentifierExpr &expr) { // TODO: same thing as visit(PathInExpression) here? + tl::optional<NodeId> resolved = tl::nullopt; auto label = ctx.labels.get (expr.get_ident ()); auto value = ctx.values.get (expr.get_ident ()); - rust_debug ("[ARTHUR] label: %d", label ? *label : -1); - rust_debug ("[ARTHUR] value: %d", value ? *value : -1); + if (label) + resolved = label; + else if (value) + resolved = value; + // TODO: else emit error? + + ctx.map_usage (expr.get_node_id (), *resolved); + + // in the old resolver, resolutions are kept in the resolver, not the mappings + // :/ how do we deal with that? + // ctx.mappings.insert_resolved_name(expr, resolved); + + // For empty types, do we perform a lookup in ctx.types or should the + // toplevel instead insert a name in ctx.values? (like it currently does) } void @@ -136,11 +150,20 @@ Late::visit (AST::PathInExpression &expr) // do we emit it in `get<Namespace::Labels>`? auto label = ctx.labels.resolve_path (expr.get_segments ()); - auto value = ctx.values.resolve_path (expr.get_segments ()); +} + +void +Late::visit (AST::TypePath &type) +{ + // should we add type path resolution in `ForeverStack` directly? Since it's + // quite more complicated. + // maybe we can overload `resolve_path<Namespace::Types>` to only do + // typepath-like path resolution? that sounds good + + auto resolved = ctx.types.get (type.get_segments ().back ()->as_string ()); - rust_debug ("[ARTHUR] label: %d", label ? *label : -1); - rust_debug ("[ARTHUR] value: %d", value ? *value : -1); + ctx.map_usage (type.get_node_id (), *resolved); } } // namespace Resolver2_0 diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h b/gcc/rust/resolve/rust-late-name-resolver-2.0.h index f54bbf2eea4f..15940d053aed 100644 --- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h @@ -45,6 +45,7 @@ public: // resolutions void visit (AST::IdentifierExpr &) override; void visit (AST::PathInExpression &) override; + void visit (AST::TypePath &) override; private: /* Setup Rust's builtin types (u8, i32, !...) in the resolver */
reply other threads:[~2024-01-30 12:00 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240130120001.D75FA3858420@sourceware.org \ --to=cohenarthur@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).