-
- Downloads
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.
Showing
- gcc/rust/resolve/rust-ast-resolve-expr.cc 9 additions, 0 deletionsgcc/rust/resolve/rust-ast-resolve-expr.cc
- gcc/rust/resolve/rust-name-resolver.cc 133 additions, 0 deletionsgcc/rust/resolve/rust-name-resolver.cc
- gcc/rust/resolve/rust-name-resolver.h 17 additions, 0 deletionsgcc/rust/resolve/rust-name-resolver.h
Loading
Please register or sign in to comment