Rename "generic instance" to "specific" throughout the toolchain. (#4165)

As discussed in toolchain meeting, we want to avoid overloading the
meaning of "instance", and "specific" was the best name we found. It's a
little unorthodox and inventive, but hopefully over time will become as
unsurprising as the term "generic" is.
This commit is contained in:
Richard Smith
2024-07-25 16:42:01 +00:00
committed by GitHub
parent 70c20be91b
commit 3cb769a053
41 changed files with 370 additions and 396 deletions
+11 -11
View File
@@ -14,13 +14,13 @@ auto ScopeStack::VerifyOnFinish() -> void {
}
auto ScopeStack::Push(SemIR::InstId scope_inst_id, SemIR::NameScopeId scope_id,
SemIR::GenericInstanceId instance_id,
SemIR::SpecificId specific_id,
bool lexical_lookup_has_load_error) -> void {
// If this scope doesn't have a specific of its own, it lives in the enclosing
// scope's specific, if any.
auto enclosing_instance_id = instance_id;
if (!instance_id.is_valid() && !scope_stack_.empty()) {
enclosing_instance_id = PeekSpecificId();
auto enclosing_specific_id = specific_id;
if (!specific_id.is_valid() && !scope_stack_.empty()) {
enclosing_specific_id = PeekSpecificId();
}
compile_time_binding_stack_.PushArray();
@@ -28,7 +28,7 @@ auto ScopeStack::Push(SemIR::InstId scope_inst_id, SemIR::NameScopeId scope_id,
{.index = next_scope_index_,
.scope_inst_id = scope_inst_id,
.scope_id = scope_id,
.instance_id = enclosing_instance_id,
.specific_id = enclosing_specific_id,
.next_compile_time_bind_index = SemIR::CompileTimeBindIndex(
compile_time_binding_stack_.all_values_size()),
.lexical_lookup_has_load_error =
@@ -36,13 +36,13 @@ auto ScopeStack::Push(SemIR::InstId scope_inst_id, SemIR::NameScopeId scope_id,
if (scope_id.is_valid()) {
non_lexical_scope_stack_.push_back({.scope_index = next_scope_index_,
.name_scope_id = scope_id,
.instance_id = enclosing_instance_id});
.specific_id = enclosing_specific_id});
} else {
// For lexical lookups, unqualified lookup doesn't know how to find the
// associated generic instance, so if we start adding lexical scopes with
// generic instances, we'll need to somehow track them in lookup.
CARBON_CHECK(!instance_id.is_valid())
<< "Lexical scope should not have an associated generic instance.";
// associated specific, so if we start adding lexical scopes associated with
// specifics, we'll need to somehow track them in lookup.
CARBON_CHECK(!specific_id.is_valid())
<< "Lexical scope should not have an associated specific.";
}
// TODO: Handle this case more gracefully.
@@ -226,7 +226,7 @@ auto ScopeStack::Restore(SuspendedScope scope) -> void {
non_lexical_scope_stack_.push_back(
{.scope_index = scope.entry.index,
.name_scope_id = scope.entry.scope_id,
.instance_id = scope.entry.instance_id});
.specific_id = scope.entry.specific_id});
}
scope_stack_.push_back(std::move(scope.entry));
}