Kagome
Polkadot Runtime Engine in C++17
kagome::runtime::wavm::ModuleInstanceImpl Class Reference

#include <module_instance.hpp>

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

Public Types

enum  Error { Error::FUNC_NOT_FOUND = 1, Error::WRONG_ARG_COUNT, Error::EXECUTION_ERROR, Error::WRONG_RETURN_TYPE }
 
- 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, WAVM::Runtime::GCPointer< WAVM::Runtime::Instance > instance, WAVM::Runtime::ModuleRef module, std::shared_ptr< const CompartmentWrapper > compartment, const common::Hash256 &code_hash)
 
const common::Hash256getCodeHash () const override
 
outcome::result< PtrSizecallExportFunction (std::string_view name, common::BufferView encoded_args) const override
 
outcome::result< std::optional< WasmValue > > getGlobal (std::string_view name) const override
 
void forDataSegment (DataSegmentProcessor const &callback) const override
 
InstanceEnvironment const & getEnvironment () const override
 
outcome::result< void > resetEnvironment () override
 
- Public Member Functions inherited from kagome::runtime::ModuleInstance
virtual ~ModuleInstance ()=default
 

Private Attributes

InstanceEnvironment env_
 
WAVM::Runtime::GCPointer< WAVM::Runtime::Instance > instance_
 
WAVM::Runtime::ModuleRef module_
 
std::shared_ptr< const CompartmentWrappercompartment_
 
common::Hash256 code_hash_
 
log::Logger logger_
 

Detailed Description

Definition at line 29 of file module_instance.hpp.

Member Enumeration Documentation

Enumerator
FUNC_NOT_FOUND 
WRONG_ARG_COUNT 
EXECUTION_ERROR 
WRONG_RETURN_TYPE 

Definition at line 33 of file module_instance.hpp.

Constructor & Destructor Documentation

kagome::runtime::wavm::ModuleInstanceImpl::ModuleInstanceImpl ( InstanceEnvironment &&  env,
WAVM::Runtime::GCPointer< WAVM::Runtime::Instance >  instance,
WAVM::Runtime::ModuleRef  module,
std::shared_ptr< const CompartmentWrapper compartment,
const common::Hash256 code_hash 
)

Definition at line 85 of file module_instance.cpp.

Member Function Documentation

outcome::result< PtrSize > kagome::runtime::wavm::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 102 of file module_instance.cpp.

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

Implements kagome::runtime::ModuleInstance.

Definition at line 195 of file module_instance.cpp.

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

Implements kagome::runtime::ModuleInstance.

Definition at line 47 of file module_instance.hpp.

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

Implements kagome::runtime::ModuleInstance.

Definition at line 217 of file module_instance.cpp.

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

Implements kagome::runtime::ModuleInstance.

Definition at line 170 of file module_instance.cpp.

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

Implements kagome::runtime::ModuleInstance.

Definition at line 221 of file module_instance.cpp.

Member Data Documentation

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

Definition at line 67 of file module_instance.hpp.

std::shared_ptr<const CompartmentWrapper> kagome::runtime::wavm::ModuleInstanceImpl::compartment_
private

Definition at line 66 of file module_instance.hpp.

InstanceEnvironment kagome::runtime::wavm::ModuleInstanceImpl::env_
private

Definition at line 63 of file module_instance.hpp.

WAVM::Runtime::GCPointer<WAVM::Runtime::Instance> kagome::runtime::wavm::ModuleInstanceImpl::instance_
private

Definition at line 64 of file module_instance.hpp.

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

Definition at line 68 of file module_instance.hpp.

WAVM::Runtime::ModuleRef kagome::runtime::wavm::ModuleInstanceImpl::module_
private

Definition at line 65 of file module_instance.hpp.


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