mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Add support for _ placeholder. (#661)
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
c3c89a77a4
commit
def98d1182
@@ -171,8 +171,8 @@ auto Value::MakeContinuationValue(std::vector<Frame*> stack) -> Value* {
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeBindingPlaceholderValue(std::string name, const Value* type)
|
||||
-> const Value* {
|
||||
auto Value::MakeBindingPlaceholderValue(std::optional<std::string> name,
|
||||
const Value* type) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->value = BindingPlaceholderValue({.name = std::move(name), .type = type});
|
||||
return v;
|
||||
@@ -352,8 +352,15 @@ auto PrintValue(const Value* val, std::ostream& out) -> void {
|
||||
break;
|
||||
}
|
||||
case ValKind::BindingPlaceholderValue: {
|
||||
const BindingPlaceholderValue& placeholder =
|
||||
val->GetBindingPlaceholderValue();
|
||||
if (placeholder.name.has_value()) {
|
||||
out << *placeholder.name;
|
||||
} else {
|
||||
out << "_";
|
||||
}
|
||||
out << ": ";
|
||||
PrintValue(val->GetBindingPlaceholderValue().type, out);
|
||||
out << ": " << val->GetBindingPlaceholderValue().name;
|
||||
break;
|
||||
}
|
||||
case ValKind::AlternativeValue: {
|
||||
|
||||
Reference in New Issue
Block a user