Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
host_function.hpp File Reference
#include <sysio/vm/allocator.hpp>
#include <sysio/vm/execution_interface.hpp>
#include <sysio/vm/function_traits.hpp>
#include <sysio/vm/argument_proxy.hpp>
#include <sysio/vm/span.hpp>
#include <sysio/vm/utils.hpp>
#include <sysio/vm/wasm_stack.hpp>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
Include dependency graph for host_function.hpp:

Go to the source code of this file.

Classes

struct  sysio::vm::no_match_t
 
struct  sysio::vm::invoke_on_all_t
 
struct  sysio::vm::running_context< Host_Type, Execution_Interface >
 
struct  sysio::vm::tag< T >
 
struct  sysio::vm::type_converter< Host, Execution_Interface >
 
struct  sysio::vm::host_function
 
struct  sysio::vm::host_func_pair_hash
 
struct  sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >
 
struct  sysio::vm::registered_host_functions< Cls, Execution_Interface, Type_Converter >::mappings
 

Namespaces

namespace  sysio
 
namespace  sysio::vm
 
namespace  sysio::vm::detail
 

Macros

#define SYS_VM_FROM_WASM_ADD_TAG(...)
 
#define SYS_VM_FROM_WASM(TYPE, PARAMS)
 
#define SYS_VM_INVOKE_ON(TYPE, CONDITION)
 
#define SYS_VM_INVOKE_ON_ALL(CONDITION)
 
#define SYS_VM_INVOKE_ONCE(CONDITION)
 
#define SYS_VM_PRECONDITION(NAME, ...)
 

Typedefs

typedef std::nullptr_t sysio::vm::standalone_function_t
 
template<typename T >
using sysio::vm::detail::strip_tag
 
template<class TC , typename T >
using sysio::vm::detail::from_wasm_type_deducer_t = strip_tag<flatten_parameters_t<&TC::template from_wasm<T>>>
 
template<class TC , typename T >
using sysio::vm::detail::to_wasm_type_deducer_t = decltype(std::declval<TC>().to_wasm(std::declval<T>()))
 
using sysio::vm::host_func_pair = std::pair<std::string, std::string>
 

Functions

template<typename Tuple , std::size_t... N>
std::tuple< std::tuple_element_t< N, Tuple >... > sysio::vm::detail::tuple_select (std::index_sequence< N... >)
 
template<std::size_t N, typename Type_Converter >
constexpr const auto & sysio::vm::detail::pop_value (Type_Converter &tc)
 
template<typename S , typename Type_Converter >
constexpr bool sysio::vm::detail::has_as_value ()
 
template<typename S , typename Type_Converter >
constexpr bool sysio::vm::detail::has_as_result ()
 
template<typename T , class Type_Converter >
constexpr std::size_t sysio::vm::detail::value_operand_size ()
 
template<typename Args , std::size_t I, class Type_Converter >
constexpr std::size_t sysio::vm::detail::total_operands ()
 
template<typename Args , typename S , std::size_t At, class Type_Converter , std::size_t... Is>
constexpr decltype(auto) sysio::vm::detail::create_value (Type_Converter &tc, std::index_sequence< Is... >)
 
template<typename S , typename Type_Converter >
constexpr std::size_t sysio::vm::detail::skip_amount ()
 
template<typename Args , std::size_t At, std::size_t Skip_Amt, class Type_Converter >
constexpr auto sysio::vm::detail::get_values (Type_Converter &tc)
 
template<typename Type_Converter , typename T >
constexpr auto sysio::vm::detail::resolve_result (Type_Converter &tc, T &&val)
 
template<bool Once, std::size_t Cnt, typename T , typename F >
constexpr void sysio::vm::detail::invoke_on_impl (F &&fn)
 
template<bool Once, std::size_t Cnt, typename T , typename F , typename Arg , typename... Args>
constexpr void sysio::vm::detail::invoke_on_impl (F &&fn, const Arg &arg, const Args &... args)
 
template<bool Once, typename T , typename F , typename... Args>
void sysio::vm::invoke_on (F &&func, const Args &... args)
 
template<auto F, typename Preconditions , typename Type_Converter , typename Host , typename... Args>
decltype(auto) sysio::vm::invoke_impl (Type_Converter &tc, Host *host, Args &&... args)
 
template<auto F, typename Preconditions , typename Host , typename Args , typename Type_Converter , std::size_t... Is>
decltype(auto) sysio::vm::invoke_with_host_impl (Type_Converter &tc, Host *host, Args &&args, std::index_sequence< Is... >)
 
template<auto F, typename Preconditions , typename Args , typename Type_Converter , typename Host , std::size_t... Is>
decltype(auto) sysio::vm::invoke_with_host (Type_Converter &tc, Host *host, std::index_sequence< Is... >)
 
template<typename Type_Converter , typename T >
void sysio::vm::maybe_push_result (Type_Converter &tc, T &&res, std::size_t trim_amt)
 
template<typename Cls , auto F, typename Preconditions , typename R , typename Args , typename Type_Converter , size_t... Is>
auto sysio::vm::create_function (std::index_sequence< Is... >)
 
template<typename T >
auto sysio::vm::to_wasm_type ()
 
template<>
constexpr auto sysio::vm::to_wasm_type< i32_const_t > ()
 
template<>
constexpr auto sysio::vm::to_wasm_type< i64_const_t > ()
 
template<>
constexpr auto sysio::vm::to_wasm_type< f32_const_t > ()
 
template<>
constexpr auto sysio::vm::to_wasm_type< f64_const_t > ()
 
bool sysio::vm::operator== (const host_function &lhs, const func_type &rhs)
 
bool sysio::vm::operator== (const func_type &lhs, const host_function &rhs)
 
template<typename TC , typename Args , std::size_t... Is>
void sysio::vm::get_args (value_type *&out, std::index_sequence< Is... >)
 
template<typename Type_Converter , typename T >
void sysio::vm::get_args (value_type *&out)
 

Variables

template<typename T >
constexpr bool sysio::vm::detail::is_tag_v = false
 
template<typename T >
constexpr bool sysio::vm::detail::is_tag_v< tag< T > > = true
 
template<typename TC , typename T >
constexpr auto sysio::vm::to_wasm_type_v = to_wasm_type<decltype(detail::resolve_result(std::declval<TC&>(), std::declval<T>()))>()
 
template<typename TC >
constexpr auto sysio::vm::to_wasm_type_v< TC, void > = types::ret_void
 
template<typename Type_Converter , typename Ret , typename Args , std::size_t... Is>
host_function sysio::vm::function_types_provider (std::index_sequence< Is... >)
 

Macro Definition Documentation

◆ SYS_VM_FROM_WASM

#define SYS_VM_FROM_WASM ( TYPE,
PARAMS )
Value:
template <typename T> \
auto from_wasm SYS_VM_FROM_WASM_ADD_TAG PARAMS const -> std::enable_if_t<std::is_same_v<T, TYPE>, TYPE>
#define SYS_VM_FROM_WASM_ADD_TAG(...)

Definition at line 63 of file host_function.hpp.

63#define SYS_VM_FROM_WASM(TYPE, PARAMS) \
64 template <typename T> \
65 auto from_wasm SYS_VM_FROM_WASM_ADD_TAG PARAMS const -> std::enable_if_t<std::is_same_v<T, TYPE>, TYPE>

◆ SYS_VM_FROM_WASM_ADD_TAG

#define SYS_VM_FROM_WASM_ADD_TAG ( ...)
Value:

Definition at line 61 of file host_function.hpp.

◆ SYS_VM_INVOKE_ON

#define SYS_VM_INVOKE_ON ( TYPE,
CONDITION )
Value:
sysio::vm::invoke_on<false, TYPE>(CONDITION, args...);
void invoke_on(F &&func, const Args &... args)

Definition at line 287 of file host_function.hpp.

287#define SYS_VM_INVOKE_ON(TYPE, CONDITION) \
288 sysio::vm::invoke_on<false, TYPE>(CONDITION, args...);

◆ SYS_VM_INVOKE_ON_ALL

#define SYS_VM_INVOKE_ON_ALL ( CONDITION)
Value:

Definition at line 290 of file host_function.hpp.

290#define SYS_VM_INVOKE_ON_ALL(CONDITION) \
291 sysio::vm::invoke_on<false, sysio::vm::invoke_on_all_t>(CONDITION, args...);

◆ SYS_VM_INVOKE_ONCE

#define SYS_VM_INVOKE_ONCE ( CONDITION)
Value:

Definition at line 293 of file host_function.hpp.

293#define SYS_VM_INVOKE_ONCE(CONDITION) \
294 sysio::vm::invoke_on<true, sysio::vm::invoke_on_all_t>(CONDITION, args...);

◆ SYS_VM_PRECONDITION

#define SYS_VM_PRECONDITION ( NAME,
... )
Value:
struct NAME { \
template <typename Type_Converter, typename... Args> \
inline static decltype(auto) condition(Type_Converter& ctx, const Args&... args) { \
__VA_ARGS__; \
} \
};
#define NAME(s)

Definition at line 296 of file host_function.hpp.

296#define SYS_VM_PRECONDITION(NAME, ...) \
297 struct NAME { \
298 template <typename Type_Converter, typename... Args> \
299 inline static decltype(auto) condition(Type_Converter& ctx, const Args&... args) { \
300 __VA_ARGS__; \
301 } \
302 };