Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
pure_memory.hpp
Go to the documentation of this file.
1#pragma once
2
6
7namespace bb::avm2::simulation {
8
9// Just a map that doesn't emit events or do anything else.
11 public:
15
16 const MemoryValue& get(MemoryAddress index) const override
17 {
18 static const auto default_value = MemoryValue::from<FF>(0);
19 auto it = memory.find(index);
20 const auto& vt = it != memory.end() ? it->second : default_value;
21 debug("Memory read: ", index, " -> ", vt.to_string());
22 return vt;
23 }
24 void set(MemoryAddress index, MemoryValue value) override
25 {
26 memory[index] = value;
27 debug("Memory write: ", index, " <- ", value.to_string());
28 }
29 uint16_t get_space_id() const override { return space_id; }
30
31 private:
34};
35
37 public:
38 PureMemoryProvider() = default;
39 ~PureMemoryProvider() override = default;
41 {
42 return std::make_unique<MemoryStore>(space_id);
43 }
44};
45
46} // namespace bb::avm2::simulation
std::string to_string() const
MemoryStore(uint16_t space_id=0)
void set(MemoryAddress index, MemoryValue value) override
uint16_t get_space_id() const override
const MemoryValue & get(MemoryAddress index) const override
unordered_flat_map< MemoryAddress, MemoryValue > memory
std::unique_ptr< MemoryInterface > make_memory(uint16_t space_id) override
#define debug(...)
Definition log.hpp:61
uint32_t MemoryAddress
::ankerl::unordered_dense::map< Key, T > unordered_flat_map
Definition map.hpp:15
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13