mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add name accessor to NamedEntityView (#994)
This required changing BindingPattern::name() to return `"_"` instead of nullopt when representing a `"_"` binding. Semi-related drive-by fixes: - Update BindingPlaceholderValue to expose a NamedEntity instead of a string name, and stop exposing its type. - Drop the unused SourceLocation parameter of ValueEqual
This commit is contained in:
@@ -28,8 +28,8 @@ static void AddExposedNames(const Member& member,
|
||||
switch (member.kind()) {
|
||||
case MemberKind::FieldMember: {
|
||||
const auto& field = cast<FieldMember>(member);
|
||||
if (field.binding().name().has_value()) {
|
||||
enclosing_scope.Add(*field.binding().name(), &field.binding());
|
||||
if (field.binding().name() != AnonymousName) {
|
||||
enclosing_scope.Add(field.binding().name(), &field.binding());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -56,8 +56,8 @@ static void AddExposedNames(const Declaration& declaration,
|
||||
}
|
||||
case DeclarationKind::VariableDeclaration:
|
||||
auto& var = cast<VariableDeclaration>(declaration);
|
||||
if (var.binding().name().has_value()) {
|
||||
enclosing_scope.Add(*(var.binding().name()), &var.binding());
|
||||
if (var.binding().name() != AnonymousName) {
|
||||
enclosing_scope.Add(var.binding().name(), &var.binding());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -158,8 +158,8 @@ static void ResolveNames(Pattern& pattern, StaticScope& enclosing_scope) {
|
||||
case PatternKind::BindingPattern: {
|
||||
auto& binding = cast<BindingPattern>(pattern);
|
||||
ResolveNames(binding.type(), enclosing_scope);
|
||||
if (binding.name().has_value()) {
|
||||
enclosing_scope.Add(*binding.name(), &binding);
|
||||
if (binding.name() != AnonymousName) {
|
||||
enclosing_scope.Add(binding.name(), &binding);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ static void ResolveNames(Statement& statement, StaticScope& enclosing_scope) {
|
||||
}
|
||||
case StatementKind::Continuation: {
|
||||
auto& continuation = cast<Continuation>(statement);
|
||||
enclosing_scope.Add(continuation.continuation_variable(), &continuation);
|
||||
enclosing_scope.Add(continuation.name(), &continuation);
|
||||
StaticScope continuation_scope;
|
||||
continuation_scope.AddParent(&enclosing_scope);
|
||||
ResolveNames(cast<Continuation>(statement).body(), continuation_scope);
|
||||
|
||||
Reference in New Issue
Block a user