Kagome
Polkadot Runtime Engine in C++17
binaryen_memory_provider.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_RUNTIME_BINARYEN_BINARYEN_MEMORY_PROVIDER_HPP
7 #define KAGOME_CORE_RUNTIME_BINARYEN_BINARYEN_MEMORY_PROVIDER_HPP
8 
13 
14 namespace wasm {
15  class RuntimeExternalInterface;
16 }
17 
18 namespace kagome::runtime::binaryen {
19 
20  class BinaryenMemoryProvider final : public MemoryProvider {
21  public:
22  enum class Error { OUTDATED_EXTERNAL_INTERFACE = 1 };
23 
25  std::shared_ptr<const BinaryenMemoryFactory> memory_factory);
26 
27  std::optional<std::reference_wrapper<runtime::Memory>> getCurrentMemory()
28  const override;
29 
30  [[nodiscard]] outcome::result<void> resetMemory(
31  WasmSize heap_base) override;
32 
33  void setExternalInterface(std::weak_ptr<RuntimeExternalInterface> rei);
34 
35  private:
36  std::weak_ptr<RuntimeExternalInterface> external_interface_;
37  std::shared_ptr<const BinaryenMemoryFactory> memory_factory_;
38  std::shared_ptr<MemoryImpl> memory_;
39  };
40 
41 } // namespace kagome::runtime::binaryen
42 
45 
46 #endif // KAGOME_CORE_RUNTIME_BINARYEN_BINARYEN_MEMORY_PROVIDER_HPP
uint32_t WasmSize
Size type is uint32_t because we are working in 32 bit address space.
Definition: types.hpp:35
std::shared_ptr< const BinaryenMemoryFactory > memory_factory_
OUTCOME_HPP_DECLARE_ERROR(kagome::runtime::binaryen, BinaryenMemoryProvider::Error)
std::weak_ptr< RuntimeExternalInterface > external_interface_