Distinguish between name IDs and string IDs in the type system. (#3341)

Add a `NameId` that is effectively just a wrapper around a `StringId`,
with
some additional predefined values for names that don't correspond to
strings, such as the name of `self` or the function's return slot.
This commit is contained in:
Richard Smith
2023-11-09 16:51:36 +00:00
committed by GitHub
parent 84bc8cc4bf
commit 71aa4a45be
206 changed files with 1050 additions and 921 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ auto DeclarationNameStack::MakeEmptyNameContext() -> NameContext {
}
auto DeclarationNameStack::MakeUnqualifiedName(Parse::Node parse_node,
IdentifierId name_id)
SemIR::NameId name_id)
-> NameContext {
NameContext context = MakeEmptyNameContext();
ApplyNameQualifierTo(context, parse_node, name_id);
@@ -103,13 +103,13 @@ auto DeclarationNameStack::AddNameToLookup(NameContext name_context,
}
auto DeclarationNameStack::ApplyNameQualifier(Parse::Node parse_node,
IdentifierId name_id) -> void {
SemIR::NameId name_id) -> void {
ApplyNameQualifierTo(declaration_name_stack_.back(), parse_node, name_id);
}
auto DeclarationNameStack::ApplyNameQualifierTo(NameContext& name_context,
Parse::Node parse_node,
IdentifierId name_id) -> void {
SemIR::NameId name_id) -> void {
if (CanResolveQualifier(name_context, parse_node)) {
// For identifier nodes, we need to perform a lookup on the identifier.
auto resolved_inst_id = context_->LookupNameInDeclaration(