mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:41:04 +01:00
Split global init out from InstBlockStack. (#4101)
Creates a `GlobalInit` class for storing relevant values, pulling functions off `InstBlockStack` and `Context`. Adds a `Context` pointer just so that it doesn't need to be passed in on each call (`Finalize` in particular uses several members). Note we have several different `InstBlockStack` instances, so several copies of the relevant members were simply unused.
This commit is contained in:
@@ -21,9 +21,10 @@ auto InstBlockStack::Push(SemIR::InstBlockId id) -> void {
|
||||
++size_;
|
||||
}
|
||||
|
||||
auto InstBlockStack::PushGlobalInit() -> void {
|
||||
Push(init_block_id_);
|
||||
stack_[size_ - 1].content = std::move(init_block_);
|
||||
auto InstBlockStack::Push(SemIR::InstBlockId id,
|
||||
llvm::ArrayRef<SemIR::InstId> inst_ids) -> void {
|
||||
Push(id);
|
||||
stack_[size_ - 1].content = inst_ids;
|
||||
}
|
||||
|
||||
auto InstBlockStack::PeekOrAdd(int depth) -> SemIR::InstBlockId {
|
||||
@@ -57,12 +58,6 @@ auto InstBlockStack::Pop() -> SemIR::InstBlockId {
|
||||
return back.id;
|
||||
}
|
||||
|
||||
auto InstBlockStack::PopGlobalInit() -> void {
|
||||
init_block_ = std::move(stack_[size_ - 1].content);
|
||||
init_block_id_ = stack_[size_ - 1].id;
|
||||
PopAndDiscard();
|
||||
}
|
||||
|
||||
auto InstBlockStack::PopAndDiscard() -> void {
|
||||
CARBON_CHECK(!empty()) << "no current block";
|
||||
--size_;
|
||||
|
||||
Reference in New Issue
Block a user