Refactor BindName to support tracking the enclosing scope. (#3566)

This is a step towards adding enclosing scopes for imports. It creates
an indirection for all bind names.

We discussed specializing for bindings that are in function scope (i.e.,
not a useful enclosing scope for imports or diagnostics). However, the
thought is to go ahead with this singular approach for now, and only
change structure if it's a performance issues so that we have
incrementally fewer instructions to handle.
This commit is contained in:
Jon Ross-Perkins
2024-01-05 02:56:03 +00:00
committed by GitHub
parent dfb27ded9c
commit 0205645e7d
18 changed files with 82 additions and 16 deletions
+3 -2
View File
@@ -262,8 +262,9 @@ auto HandleFunctionDefinitionStart(Context& context,
});
if (auto fn_param = param.TryAs<SemIR::BindName>()) {
context.AddNameToLookup(fn_param->parse_node, fn_param->name_id,
param_id);
context.AddNameToLookup(
fn_param->parse_node,
context.bind_names().Get(fn_param->bind_name_id).name_id, param_id);
} else {
CARBON_FATAL() << "Unexpected kind of parameter in function definition "
<< param;