Files
carbon-lang/toolchain/check/generic_region_stack.cpp
T
Jon Ross-PerkinsandChandler Carruth d437e4bffe Create an array stack type for a shared use-case (#4100)
Based on discussion around the region handling in generic_region_stack,
create a generic structure for the stack-of-vectors support. I also want
to add this to InstBlockStack, but that's a little more complex due to
GlobalInit, so cutting a PR here to check with review.

My work here is how I noticed #4099; I want to be sure that I'm correct
about the issue, but it's the difference between being able to use
PeekArray or not.

Note in scope_stack.h, I believe we could remove next_compile_time_index
and make it just based on elements_size(). However, I want to verify
with you before I make further changes there.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2024-07-03 16:58:47 +00:00

22 lines
709 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/check/generic_region_stack.h"
namespace Carbon::Check {
auto GenericRegionStack::Push() -> void { dependent_insts_stack_.PushArray(); }
auto GenericRegionStack::Pop() -> void { dependent_insts_stack_.PopArray(); }
auto GenericRegionStack::AddDependentInst(DependentInst inst) -> void {
dependent_insts_stack_.AppendToTop(inst);
}
auto GenericRegionStack::PeekDependentInsts() -> llvm::ArrayRef<DependentInst> {
return dependent_insts_stack_.PeekArray();
}
} // namespace Carbon::Check