diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-10-21 13:40:40 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-02-21 12:36:52 +0100 |
commit | f7c258b291182308538ff18c3ace76b1c11e699a (patch) | |
tree | 44ad68a4642decc066855aded1eb396185c8ba7b /gcc/rust/backend/rust-mangle.h | |
parent | 32a4659c5e405771dc8c83568b30efefc77a2031 (diff) | |
download | gcc-f7c258b291182308538ff18c3ace76b1c11e699a.zip gcc-f7c258b291182308538ff18c3ace76b1c11e699a.tar.gz gcc-f7c258b291182308538ff18c3ace76b1c11e699a.tar.bz2 |
gccrs: Add closure binding's tracking to name resolution
When we have a closure block referencing variables in a parent function,
we must track what these are. We do this by having a context of closures
so if we have a variable reference and its declared in a rib whose node id
is less than the node id of the closure's node id we know it must be a
captured variable. We also need to iterate all possible closure contexts
as we might be in the case of a nested closure.
Addresses #195
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Use proper closure
contexts.
* resolve/rust-name-resolver.cc (Scope::lookup_decl_type): New function.
(Scope::lookup_rib_for_decl): Likewise.
(Resolver::insert_resolved_name): Insert captured items.
(Resolver::push_closure_context): New function.
(Resolver::pop_closure_context): Likewise.
(Resolver::insert_captured_item): Likewise.
(Resolver::decl_needs_capture): Likewise.
(Resolver::get_captures): Likewise.
* resolve/rust-name-resolver.h: Declare new functions.
Diffstat (limited to 'gcc/rust/backend/rust-mangle.h')
0 files changed, 0 insertions, 0 deletions