mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -144,9 +144,11 @@ auto Context::AddPackageImports(Parse::NodeId import_node,
|
||||
// Add a name for formatted output. This isn't used in name lookup in order
|
||||
// to reduce indirection, but it's separate from the Import because it
|
||||
// otherwise fits in an Inst.
|
||||
auto bind_name_id = bind_names().Add(
|
||||
{.name_id = name_id, .enclosing_scope_id = SemIR::NameScopeId::Package});
|
||||
AddInst(SemIR::BindName{.parse_node = import_node,
|
||||
.type_id = type_id,
|
||||
.name_id = name_id,
|
||||
.bind_name_id = bind_name_id,
|
||||
.value_id = inst_id});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user