Kagome
Polkadot Runtime Engine in C++17
kagome::runtime::binaryen::ModuleInstanceImpl Class Referencefinal

#include <module_instance_impl.hpp>

Inheritance diagram for kagome::runtime::binaryen::ModuleInstanceImpl:
Collaboration diagram for kagome::runtime::binaryen::ModuleInstanceImpl:

Public Types

enum  Error { Error::UNEXPECTED_EXIT = 1, Error::EXECUTION_ERROR, Error::CAN_NOT_OBTAIN_GLOBAL }
 
- Public Types inherited from kagome::runtime::ModuleInstance
using SegmentOffset = size_t
 
using SegmentData = gsl::span< const uint8_t >
 
using DataSegmentProcessor = std::function< void(SegmentOffset, SegmentData)>
 

Public Member Functions

 ModuleInstanceImpl (InstanceEnvironment &&env, std::shared_ptr< wasm::Module > parent, std::shared_ptr< RuntimeExternalInterface > rei, const common::Hash256 &code_hash)
 
const common::Hash256getCodeHash () const override
 
outcome::result< PtrSizecallExportFunction (std::string_view name, common::BufferView args) const override
 
outcome::result< std::optional< WasmValue > > getGlobal (std::string_view name) const override
 
InstanceEnvironment const & getEnvironment () const override
 
outcome::result< void > resetEnvironment () override
 
void forDataSegment (DataSegmentProcessor const &callback) const override
 
- Public Member Functions inherited from kagome::runtime::ModuleInstance
virtual ~ModuleInstance ()=default
 

Private Attributes

InstanceEnvironment env_
 
std::shared_ptr< RuntimeExternalInterfacerei_
 
std::shared_ptr< wasm::Module > parent_
 
common::Hash256 code_hash_
 
std::unique_ptr< wasm::ModuleInstance > module_instance_
 
log::Logger logger_
 

Detailed Description

Definition at line 23 of file module_instance_impl.hpp.

Member Enumeration Documentation

Enumerator
UNEXPECTED_EXIT 
EXECUTION_ERROR 
CAN_NOT_OBTAIN_GLOBAL 

Definition at line 25 of file module_instance_impl.hpp.

Constructor & Destructor Documentation

kagome::runtime::binaryen::ModuleInstanceImpl::ModuleInstanceImpl ( InstanceEnvironment &&  env,
std::shared_ptr< wasm::Module >  parent,
std::shared_ptr< RuntimeExternalInterface rei,
const common::Hash256 code_hash 
)

Definition at line 76 of file module_instance_impl.cpp.

Member Function Documentation

outcome::result< PtrSize > kagome::runtime::binaryen::ModuleInstanceImpl::callExportFunction ( std::string_view  name,
common::BufferView  encoded_args 
) const
overridevirtual

Call the instance's function

Parameters
name- name of the function
args- a pointer-size describing a buffer with the function parameters
Returns
a pointer-size with the buffer returned by the call

Implements kagome::runtime::ModuleInstance.

Definition at line 93 of file module_instance_impl.cpp.

void kagome::runtime::binaryen::ModuleInstanceImpl::forDataSegment ( DataSegmentProcessor const &  callback) const
overridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 148 of file module_instance_impl.cpp.

const common::Hash256& kagome::runtime::binaryen::ModuleInstanceImpl::getCodeHash ( ) const
inlineoverridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 36 of file module_instance_impl.hpp.

InstanceEnvironment const & kagome::runtime::binaryen::ModuleInstanceImpl::getEnvironment ( ) const
overridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 139 of file module_instance_impl.cpp.

outcome::result< std::optional< WasmValue > > kagome::runtime::binaryen::ModuleInstanceImpl::getGlobal ( std::string_view  name) const
overridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 115 of file module_instance_impl.cpp.

outcome::result< void > kagome::runtime::binaryen::ModuleInstanceImpl::resetEnvironment ( )
overridevirtual

Implements kagome::runtime::ModuleInstance.

Definition at line 143 of file module_instance_impl.cpp.

Member Data Documentation

common::Hash256 kagome::runtime::binaryen::ModuleInstanceImpl::code_hash_
private

Definition at line 58 of file module_instance_impl.hpp.

InstanceEnvironment kagome::runtime::binaryen::ModuleInstanceImpl::env_
private

Definition at line 53 of file module_instance_impl.hpp.

log::Logger kagome::runtime::binaryen::ModuleInstanceImpl::logger_
private

Definition at line 61 of file module_instance_impl.hpp.

std::unique_ptr<wasm::ModuleInstance> kagome::runtime::binaryen::ModuleInstanceImpl::module_instance_
private

Definition at line 60 of file module_instance_impl.hpp.

std::shared_ptr<wasm::Module> kagome::runtime::binaryen::ModuleInstanceImpl::parent_
private

Definition at line 56 of file module_instance_impl.hpp.

std::shared_ptr<RuntimeExternalInterface> kagome::runtime::binaryen::ModuleInstanceImpl::rei_
private

Definition at line 54 of file module_instance_impl.hpp.


The documentation for this class was generated from the following files: