mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 21:28:10 +00:00
Clean up interface of node block stack after recent changes. (#3229)
- `Peek()` no longer returns a useful value, because we often don't allocate a `NodeBlockId` until we finish building the block. Remove it and update both its callers. - Rename `PeekForAdd()` to `PeekOrAdd()` since it's no longer used to get a block ID to add elements into. - `PushForAdd()` was unused. Remove it. - Add `NodeBlockStack::AddNode` to combine the operations of adding a node and inserting it into a block.
This commit is contained in:
1 parent
e81d171226
commit
85d5b40429
7 files changed
+50
-52
No files matched your search
@@ -22,13 +22,12 @@ auto NodeBlockStack::Push(SemIR::NodeBlockId id) -> void {
|
||||
++size_;
|
||||
}
|
||||
|
||||
auto NodeBlockStack::PeekForAdd(int depth) -> SemIR::NodeBlockId {
|
||||
auto NodeBlockStack::PeekOrAdd(int depth) -> SemIR::NodeBlockId {
|
||||
CARBON_CHECK(size() > depth) << "no such block";
|
||||
int index = size() - depth - 1;
|
||||
auto& slot = stack_[index];
|
||||
if (!slot.id.is_valid()) {
|
||||
slot.id = semantics_ir_->AddNodeBlockId();
|
||||
CARBON_VLOG() << name_ << " Add " << index << ": " << slot.id << "\n";
|
||||
}
|
||||
return slot.id;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user