diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-06-03 15:12:00 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-06-10 17:09:34 +0100 |
commit | 7ca7362602d4e827ecbc39d5cfdf56df9044633b (patch) | |
tree | 7e149ddc7c9ffb0f72bcd4be2459abc7d1ee688a /gcc/rust/backend/rust-compile-expr.h | |
parent | fc3ef6c4b1fad0d88a65043df8102437416b1df3 (diff) | |
download | gcc-7ca7362602d4e827ecbc39d5cfdf56df9044633b.zip gcc-7ca7362602d4e827ecbc39d5cfdf56df9044633b.tar.gz gcc-7ca7362602d4e827ecbc39d5cfdf56df9044633b.tar.bz2 |
This patch implements complex Path resolution
This patch completely reimplements our name resolution process for Paths in
general. This patch gets rid of the old Resolver::Definition structures
which were used so that we can map patterns back to LetStmts and establish
an hierarchy of nodes. This was not nessecary and complicated name/type
resolution.
TypePaths and PathInExpression are similar but have a slightl tweak in the
order they lookup the relevant scopes for types. But overall work the same.
There are several cases of paths you must consider in type resolution:
- i32 (simple type path)
- Self::A (associated type reference)
- mod::foo::impl_item() (reference to impl item)
- super::foo (reference to impl item)
- crate::foo
- T::bound()
In name resolution we cannot always fully resolve a path but have to rely
on the type-resolution to fully resolve a path as it may require careful
thought. For example a path like:
mod::foo::item()
might be for a generic foo<T>(), which might have two specialized impl
blocks so the best the name resolution can do is resolve mod::foo then
leave it up to the type resolution to figure out which item this is. We
might have i32 which is just a simple lookup.
Apart from that this patch introduces a module parent child hierachy so
that on paths such as super::foo we resolve super to be our parent module
scope then foo can be resolved with the lookup in the items for that
module.
More over this patch gets rid of some but not all of the awkward name
canonicalization to try and patch paths directly. More cleanup is still
needed here to make the name resolution step easier to read. This was
notable in the Qualified path handling where we can now rely on the type
resolver to setup the associated types properly rather than the name
resolver requiring us to resolve this directly.
Fixes #1251 #1230
Addresses #1227 #1153
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 593e1f9..3b729c7 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -512,8 +512,8 @@ public: void visit (HIR::FieldAccessExpr &expr) override { - tree receiver_ref - = CompileExpr::Compile (expr.get_receiver_expr ().get (), ctx); + HIR::Expr *receiver_expr = expr.get_receiver_expr ().get (); + tree receiver_ref = CompileExpr::Compile (receiver_expr, ctx); // resolve the receiver back to ADT type TyTy::BaseType *receiver = nullptr; |