Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter > Struct Template Reference

#include <host_function.hpp>

Classes

struct  mappings
 

Public Types

using host_type_t = Cls
 
using execution_interface_t = Execution_Interface
 
using type_converter_t = Type_Converter
 

Public Member Functions

void operator() (Cls *host, Execution_Interface ei, uint32_t index)
 
void operator() (Cls *host, Execution_Interface ei, uint32_t index)
 

Static Public Member Functions

template<auto Func, typename... Preconditions>
static void add (const std::string &mod, const std::string &name)
 
template<typename Module >
static void resolve (Module &mod)
 
template<auto Func, typename... Preconditions>
static void add (const std::string &mod, const std::string &name)
 
template<typename Module >
static void resolve (Module &mod)
 

Detailed Description

template<typename Cls, typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
struct sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >

Definition at line 419 of file host_function.hpp.

Member Typedef Documentation

◆ execution_interface_t

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
typedef Execution_Interface sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::execution_interface_t = Execution_Interface

Definition at line 421 of file host_function.hpp.

◆ host_type_t

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
typedef Cls sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::host_type_t = Cls

Definition at line 420 of file host_function.hpp.

◆ type_converter_t

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
typedef Type_Converter sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::type_converter_t = Type_Converter

Definition at line 422 of file host_function.hpp.

Member Function Documentation

◆ add() [1/2]

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
template<auto Func, typename... Preconditions>
static void sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::add ( const std::string & mod,
const std::string & name )
inlinestatic

Definition at line 448 of file host_function.hpp.

448 {
450 using res = return_type_t<AUTO_PARAM_WORKAROUND(Func)>;
451 using preconditions = std::tuple<Preconditions...>;
452 mappings::get().template add_mapping<Func, res, args, preconditions>(mod, name);
453 }
std::string name
decltype(return_type(AUTO_PARAM_WORKAROUND(FN))) return_type_t
decltype(flatten_parameters(AUTO_PARAM_WORKAROUND(FN))) flatten_parameters_t
#define AUTO_PARAM_WORKAROUND(X)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add() [2/2]

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
template<auto Func, typename... Preconditions>
static void sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::add ( const std::string & mod,
const std::string & name )
inlinestatic

Definition at line 448 of file host_function.hpp.

448 {
450 using res = return_type_t<AUTO_PARAM_WORKAROUND(Func)>;
451 using preconditions = std::tuple<Preconditions...>;
452 mappings::get().template add_mapping<Func, res, args, preconditions>(mod, name);
453 }
Here is the call graph for this function:

◆ operator()() [1/2]

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
void sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::operator() ( Cls * host,
Execution_Interface ei,
uint32_t index )
inline

Definition at line 472 of file host_function.hpp.

472 {
473 const auto& _func = mappings::get().functions[index];
474 auto tc = Type_Converter{host, std::move(ei)};
475 std::invoke(_func, host, tc);
476 }
schedule config_dir_name data_dir_name p2p_port http_port file_size name host(p2p_endpoint)) FC_REFLECT(tn_node_def
std::vector< std::function< void(Cls *, Type_Converter &)> > functions
F _func
Definition sys-vm.cpp:43
Here is the call graph for this function:

◆ operator()() [2/2]

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
void sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::operator() ( Cls * host,
Execution_Interface ei,
uint32_t index )
inline

Definition at line 472 of file host_function.hpp.

472 {
473 const auto& _func = mappings::get().functions[index];
474 auto tc = Type_Converter{host, std::move(ei)};
475 std::invoke(_func, host, tc);
476 }
Here is the call graph for this function:

◆ resolve() [1/2]

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
template<typename Module >
static void sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::resolve ( Module & mod)
inlinestatic

Definition at line 456 of file host_function.hpp.

456 {
457 auto& imports = mod.import_functions;
458 auto& current_mappings = mappings::get();
459 for (std::size_t i = 0; i < mod.imports.size(); i++) {
460 std::string mod_name =
461 std::string((char*)mod.imports[i].module_str.raw(), mod.imports[i].module_str.size());
462 std::string fn_name = std::string((char*)mod.imports[i].field_str.raw(), mod.imports[i].field_str.size());
463 SYS_VM_ASSERT(current_mappings.named_mapping.count({ mod_name, fn_name }), wasm_link_exception,
464 std::string("no mapping for imported function ") + fn_name);
465 imports[i] = current_mappings.named_mapping[{ mod_name, fn_name }];
466 const import_entry& entry = mod.imports[i];
467 SYS_VM_ASSERT(entry.kind == Function, wasm_link_exception, std::string("importing non-function ") + fn_name);
468 SYS_VM_ASSERT(current_mappings.host_functions[imports[i]] == mod.types[entry.type.func_t], wasm_link_exception, std::string("wrong type for imported function ") + fn_name);
469 }
470 }
@ Function
Definition types.hpp:22
#define SYS_VM_ASSERT(expr, exc_type, msg)
Definition exceptions.hpp:8
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolve() [2/2]

template<typename Cls , typename Execution_Interface = execution_interface, typename Type_Converter = type_converter<Cls, Execution_Interface>>
template<typename Module >
static void sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::resolve ( Module & mod)
inlinestatic

Definition at line 456 of file host_function.hpp.

456 {
457 auto& imports = mod.import_functions;
458 auto& current_mappings = mappings::get();
459 for (std::size_t i = 0; i < mod.imports.size(); i++) {
460 std::string mod_name =
461 std::string((char*)mod.imports[i].module_str.raw(), mod.imports[i].module_str.size());
462 std::string fn_name = std::string((char*)mod.imports[i].field_str.raw(), mod.imports[i].field_str.size());
463 SYS_VM_ASSERT(current_mappings.named_mapping.count({ mod_name, fn_name }), wasm_link_exception,
464 std::string("no mapping for imported function ") + fn_name);
465 imports[i] = current_mappings.named_mapping[{ mod_name, fn_name }];
466 const import_entry& entry = mod.imports[i];
467 SYS_VM_ASSERT(entry.kind == Function, wasm_link_exception, std::string("importing non-function ") + fn_name);
468 SYS_VM_ASSERT(current_mappings.host_functions[imports[i]] == mod.types[entry.type.func_t], wasm_link_exception, std::string("wrong type for imported function ") + fn_name);
469 }
470 }
Here is the call graph for this function:

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