mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:01:07 +01:00
Refactor InstBlockStore's API, AddDefaultValue -> AddPlaceholder (#5166)
`AddDefaultValue` doesn't quite capture the intended semantics; it should typically be replaced with an actual value when dealing with control flows. Trying to indicate the "assign later" with `AddPlaceholder`, mirroring `AddPlaceholderInst`. Shifting the `protected` functionality on `BlockValueStore` so that it's not providing functions just for `InstBlockStore` to use. Also hoping that seeing the comments next to the function name makes them easier to understand, whereas `using` buries that a little. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
6dbcc78e6c
commit
c0ee446cec
@@ -29,7 +29,7 @@ auto InstBlockStack::PeekOrAdd(int depth) -> SemIR::InstBlockId {
|
||||
int index = id_stack_.size() - depth - 1;
|
||||
auto& slot = id_stack_[index];
|
||||
if (!slot.has_value()) {
|
||||
slot = sem_ir_->inst_blocks().AddDefaultValue();
|
||||
slot = sem_ir_->inst_blocks().AddPlaceholder();
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ auto InstBlockStack::Pop() -> SemIR::InstBlockId {
|
||||
// Finalize the block.
|
||||
if (!insts.empty() && id != SemIR::InstBlockId::Unreachable) {
|
||||
if (id.has_value()) {
|
||||
sem_ir_->inst_blocks().Set(id, insts);
|
||||
sem_ir_->inst_blocks().ReplacePlaceholder(id, insts);
|
||||
} else {
|
||||
id = sem_ir_->inst_blocks().Add(insts);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user