Skip to content
Snippets Groups Projects
Commit f7c258b2 authored by Philip Herron's avatar Philip Herron Committed by Arthur Cohen
Browse files

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.
parent 32a4659c
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment