Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
internal_call_stack_manager.cpp
Go to the documentation of this file.
2
3#include <algorithm>
4
5namespace bb::avm2::simulation {
6
7void InternalCallStackManager::push(PC caller_pc, PC return_pc)
8{
9 // Add the current call id & return_pc to the stack
10 internal_call_stack.push_back(
11 { .return_id = current_return_call_id, .caller_pc = caller_pc, .return_pc = return_pc });
12
15 .entered_call_id = next_internal_call_id,
17 .return_id = current_return_call_id,
18 .return_pc = return_pc,
19 });
20
21 // Update id values
25}
26
28{
29 if (internal_call_stack.empty()) {
30 throw InternalCallStackException("Internal call stack is empty. Cannot pop.");
31 }
32 // We need to restore the call ptr info to the previous call
33 InternalCallPtr prev_call_ptr = internal_call_stack.back();
34
35 // Reset the id values
37 current_return_call_id = prev_call_ptr.return_id;
38
39 internal_call_stack.pop_back();
40
41 // Return the next pc of the previous call
42 return prev_call_ptr.return_pc;
43}
44
49
54
59
61{
62 std::vector<PC> call_stack;
63 std::ranges::transform(internal_call_stack, std::back_inserter(call_stack), [](const InternalCallPtr& call_ptr) {
64 return call_ptr.caller_pc;
65 });
66 return call_stack;
67}
68
69} // namespace bb::avm2::simulation
void push(PC caller_pc, PC return_pc) override
EventEmitterInterface< InternalCallStackEvent > & internal_call_stack_events
uint32_t PC
uint32_t InternalCallId
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13