Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::type_converter< Host, Execution_Interface > Struct Template Reference

#include <host_function.hpp>

Inheritance diagram for sysio::vm::type_converter< Host, Execution_Interface >:
Collaboration diagram for sysio::vm::type_converter< Host, Execution_Interface >:

Public Types

using base_type = running_context<Host, Execution_Interface>
 
using elem_type = operand_stack_elem
 
- Public Types inherited from sysio::vm::running_context< Host, execution_interface >
using running_context_t
 

Public Member Functions

 SYS_VM_FROM_WASM (bool,(uint32_t value))
 
uint32_t to_wasm (bool &&value)
 
template<typename T >
no_match_t to_wasm (T &&)
 
template<typename T >
auto from_wasm (wasm_ptr_t ptr, wasm_size_t len, tag< T >={}) const -> std::enable_if_t< is_span_type_v< T >, T >
 
template<typename T >
auto from_wasm (wasm_ptr_t ptr, wasm_size_t len, tag< T >={}) const -> std::enable_if_t< is_argument_proxy_type_v< T > &&is_span_type_v< typename T::proxy_type >, T >
 
template<typename T >
auto from_wasm (wasm_ptr_t ptr, tag< T >={}) const -> std::enable_if_t< is_argument_proxy_type_v< T > &&std::is_pointer_v< typename T::proxy_type >, T >
 
template<typename T >
decltype(auto) as_value (const elem_type &val) const
 
template<typename T >
constexpr auto as_result (T &&val) const
 
 SYS_VM_FROM_WASM (bool,(uint32_t value))
 
uint32_t to_wasm (bool &&value)
 
template<typename T >
no_match_t to_wasm (T &&)
 
template<typename T >
auto from_wasm (wasm_ptr_t ptr, wasm_size_t len, tag< T >={}) const -> std::enable_if_t< is_span_type_v< T >, T >
 
template<typename T >
auto from_wasm (wasm_ptr_t ptr, wasm_size_t len, tag< T >={}) const -> std::enable_if_t< is_argument_proxy_type_v< T > &&is_span_type_v< typename T::proxy_type >, T >
 
template<typename T >
auto from_wasm (wasm_ptr_t ptr, tag< T >={}) const -> std::enable_if_t< is_argument_proxy_type_v< T > &&std::is_pointer_v< typename T::proxy_type >, T >
 
template<typename T >
decltype(auto) as_value (const elem_type &val) const
 
template<typename T >
constexpr auto as_result (T &&val) const
 
 running_context (Host_Type *host, const Execution_Interface &ei)
 
 running_context (Host_Type *host, Execution_Interface &&ei)
 
decltype(auto) get_host ()
 
- Public Member Functions inherited from sysio::vm::running_context< Host, execution_interface >
 running_context (Host *host, const execution_interface &ei)
 
 running_context (Host *host, execution_interface &&ei)
 
 running_context (Host *host, const execution_interface &ei)
 
 running_context (Host *host, execution_interface &&ei)
 
void * access (wasm_ptr_t addr=0) const
 
void * access (wasm_ptr_t addr=0) const
 
execution_interfaceget_interface ()
 
const execution_interfaceget_interface () const
 
execution_interfaceget_interface ()
 
const execution_interfaceget_interface () const
 
decltype(auto) get_host ()
 
decltype(auto) get_host ()
 
auto validate_pointer (U ptr, wasm_size_t len) const
 
auto validate_pointer (U ptr, wasm_size_t len) const
 
auto validate_null_terminated_pointer (T ptr) const
 
auto validate_null_terminated_pointer (T ptr) const
 

Additional Inherited Members

- Public Attributes inherited from sysio::vm::running_context< Host, execution_interface >
Host * host
 
execution_interface interface
 

Detailed Description

template<typename Host, typename Execution_Interface = execution_interface>
struct sysio::vm::type_converter< Host, Execution_Interface >

Definition at line 68 of file host_function.hpp.

Member Typedef Documentation

◆ base_type

template<typename Host , typename Execution_Interface = execution_interface>
typedef running_context< Host, Execution_Interface > sysio::vm::type_converter< Host, Execution_Interface >::base_type = running_context<Host, Execution_Interface>

Definition at line 69 of file host_function.hpp.

◆ elem_type

template<typename Host , typename Execution_Interface = execution_interface>
typedef operand_stack_elem sysio::vm::type_converter< Host, Execution_Interface >::elem_type = operand_stack_elem

Definition at line 74 of file host_function.hpp.

Member Function Documentation

◆ as_result() [1/2]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::as_result ( T && val) const
inlineconstexpr

Definition at line 121 of file host_function.hpp.

121 {
122 if constexpr (std::is_integral_v<T> && sizeof(T) == 4)
123 return i32_const_t{ static_cast<uint32_t>(val) };
124 else if constexpr (std::is_integral_v<T> && sizeof(T) == 8)
125 return i64_const_t{ static_cast<uint64_t>(val) };
126 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 4)
127 return f32_const_t{ static_cast<float>(val) };
128 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 8)
129 return f64_const_t{ static_cast<double>(val) };
130 else if constexpr (std::is_void_v<std::decay_t<std::remove_pointer_t<T>>>)
131 return i32_const_t{ static_cast<uint32_t>(reinterpret_cast<uintptr_t>(val) -
132 reinterpret_cast<uintptr_t>(this->access())) };
133 else
134 return no_match_t{};
135 }
#define T(meth, val, expected)
_W64 unsigned int uintptr_t
Definition stdint.h:165
unsigned int uint32_t
Definition stdint.h:126
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

◆ as_result() [2/2]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::as_result ( T && val) const
inlineconstexpr

Definition at line 121 of file host_function.hpp.

121 {
122 if constexpr (std::is_integral_v<T> && sizeof(T) == 4)
123 return i32_const_t{ static_cast<uint32_t>(val) };
124 else if constexpr (std::is_integral_v<T> && sizeof(T) == 8)
125 return i64_const_t{ static_cast<uint64_t>(val) };
126 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 4)
127 return f32_const_t{ static_cast<float>(val) };
128 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 8)
129 return f64_const_t{ static_cast<double>(val) };
130 else if constexpr (std::is_void_v<std::decay_t<std::remove_pointer_t<T>>>)
131 return i32_const_t{ static_cast<uint32_t>(reinterpret_cast<uintptr_t>(val) -
132 reinterpret_cast<uintptr_t>(this->access())) };
133 else
134 return no_match_t{};
135 }
Here is the call graph for this function:

◆ as_value() [1/2]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
decltype(auto) sysio::vm::type_converter< Host, Execution_Interface >::as_value ( const elem_type & val) const
inline

Definition at line 105 of file host_function.hpp.

105 {
106 if constexpr (std::is_integral_v<T> && sizeof(T) == 4)
107 return static_cast<T>(val.template get<i32_const_t>().data.ui);
108 else if constexpr (std::is_integral_v<T> && sizeof(T) == 8)
109 return static_cast<T>(val.template get<i64_const_t>().data.ui);
110 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 4)
111 return static_cast<T>(val.template get<f32_const_t>().data.f);
112 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 8)
113 return static_cast<T>(val.template get<f64_const_t>().data.f);
114 else if constexpr (std::is_void_v<std::decay_t<std::remove_pointer_t<T>>>)
115 return base_type::access(val.template get<i32_const_t>().data.ui);
116 else
117 return no_match_t{};
118 }
Here is the call graph for this function:

◆ as_value() [2/2]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
decltype(auto) sysio::vm::type_converter< Host, Execution_Interface >::as_value ( const elem_type & val) const
inline

Definition at line 105 of file host_function.hpp.

105 {
106 if constexpr (std::is_integral_v<T> && sizeof(T) == 4)
107 return static_cast<T>(val.template get<i32_const_t>().data.ui);
108 else if constexpr (std::is_integral_v<T> && sizeof(T) == 8)
109 return static_cast<T>(val.template get<i64_const_t>().data.ui);
110 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 4)
111 return static_cast<T>(val.template get<f32_const_t>().data.f);
112 else if constexpr (std::is_floating_point_v<T> && sizeof(T) == 8)
113 return static_cast<T>(val.template get<f64_const_t>().data.f);
114 else if constexpr (std::is_void_v<std::decay_t<std::remove_pointer_t<T>>>)
115 return base_type::access(val.template get<i32_const_t>().data.ui);
116 else
117 return no_match_t{};
118 }
Here is the call graph for this function:

◆ from_wasm() [1/6]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::from_wasm ( wasm_ptr_t ptr,
tag< T > = {} ) const -> std::enable_if_t< is_argument_proxy_type_v<T> && std::is_pointer_v<typename T::proxy_type>, T>
inline

Definition at line 97 of file host_function.hpp.

97 {}) const
98 -> std::enable_if_t< is_argument_proxy_type_v<T> &&
99 std::is_pointer_v<typename T::proxy_type>, T> {
100 auto p = this->template validate_pointer<typename T::pointee_type>(ptr, 1);
101 return {p};
102 }
const mie::Vuint & p
Definition bn.cpp:27
auto validate_pointer(U ptr, wasm_size_t len) const

◆ from_wasm() [2/6]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::from_wasm ( wasm_ptr_t ptr,
tag< T > = {} ) const -> std::enable_if_t< is_argument_proxy_type_v<T> && std::is_pointer_v<typename T::proxy_type>, T>
inline

Definition at line 97 of file host_function.hpp.

97 {}) const
98 -> std::enable_if_t< is_argument_proxy_type_v<T> &&
99 std::is_pointer_v<typename T::proxy_type>, T> {
100 auto p = this->template validate_pointer<typename T::pointee_type>(ptr, 1);
101 return {p};
102 }

◆ from_wasm() [3/6]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::from_wasm ( wasm_ptr_t ptr,
wasm_size_t len,
tag< T > = {} ) const -> std::enable_if_t< is_argument_proxy_type_v<T> && is_span_type_v<typename T::proxy_type>, T>
inline

Definition at line 89 of file host_function.hpp.

89 {}) const
90 -> std::enable_if_t< is_argument_proxy_type_v<T> &&
91 is_span_type_v<typename T::proxy_type>, T> {
92 auto p = this->template validate_pointer<typename T::pointee_type>(ptr, len);
93 return {p, len};
94 }
size_t len

◆ from_wasm() [4/6]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::from_wasm ( wasm_ptr_t ptr,
wasm_size_t len,
tag< T > = {} ) const -> std::enable_if_t< is_argument_proxy_type_v<T> && is_span_type_v<typename T::proxy_type>, T>
inline

Definition at line 89 of file host_function.hpp.

89 {}) const
90 -> std::enable_if_t< is_argument_proxy_type_v<T> &&
91 is_span_type_v<typename T::proxy_type>, T> {
92 auto p = this->template validate_pointer<typename T::pointee_type>(ptr, len);
93 return {p, len};
94 }

◆ from_wasm() [5/6]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::from_wasm ( wasm_ptr_t ptr,
wasm_size_t len,
tag< T > = {} ) const -> std::enable_if_t<is_span_type_v<T>, T>
inline

Definition at line 82 of file host_function.hpp.

82 {}) const
83 -> std::enable_if_t<is_span_type_v<T>, T> {
84 auto p = this->template validate_pointer<typename T::value_type>(ptr, len);
85 return {static_cast<typename T::pointer>(p), len};
86 }

◆ from_wasm() [6/6]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
auto sysio::vm::type_converter< Host, Execution_Interface >::from_wasm ( wasm_ptr_t ptr,
wasm_size_t len,
tag< T > = {} ) const -> std::enable_if_t<is_span_type_v<T>, T>
inline

Definition at line 82 of file host_function.hpp.

82 {}) const
83 -> std::enable_if_t<is_span_type_v<T>, T> {
84 auto p = this->template validate_pointer<typename T::value_type>(ptr, len);
85 return {static_cast<typename T::pointer>(p), len};
86 }

◆ get_host()

template<typename Host , typename Execution_Interface = execution_interface>
decltype(auto) sysio::vm::running_context< Host_Type, Execution_Interface >::get_host ( )
inline

Definition at line 41 of file host_function.hpp.

◆ running_context() [1/2]

template<typename Host , typename Execution_Interface = execution_interface>
sysio::vm::running_context< Host_Type, Execution_Interface >::running_context ( Host_Type * host,
const Execution_Interface & ei )
inlineexplicit

Definition at line 33 of file host_function.hpp.

◆ running_context() [2/2]

template<typename Host , typename Execution_Interface = execution_interface>
sysio::vm::running_context< Host_Type, Execution_Interface >::running_context ( Host_Type * host,
Execution_Interface && ei )
inlineexplicit

Definition at line 34 of file host_function.hpp.

34: host(host), interface(ei) {}

◆ SYS_VM_FROM_WASM() [1/2]

template<typename Host , typename Execution_Interface = execution_interface>
sysio::vm::type_converter< Host, Execution_Interface >::SYS_VM_FROM_WASM ( bool ,
(uint32_t value)  )
inline

Definition at line 76 of file host_function.hpp.

76{ return value ? 1 : 0; }
#define value
Definition pkcs11.h:157

◆ SYS_VM_FROM_WASM() [2/2]

template<typename Host , typename Execution_Interface = execution_interface>
sysio::vm::type_converter< Host, Execution_Interface >::SYS_VM_FROM_WASM ( bool ,
(uint32_t value)  )
inline

Definition at line 76 of file host_function.hpp.

76{ return value ? 1 : 0; }

◆ to_wasm() [1/4]

template<typename Host , typename Execution_Interface = execution_interface>
uint32_t sysio::vm::type_converter< Host, Execution_Interface >::to_wasm ( bool && value)
inline

Definition at line 77 of file host_function.hpp.

77{ return value ? 1 : 0; }

◆ to_wasm() [2/4]

template<typename Host , typename Execution_Interface = execution_interface>
uint32_t sysio::vm::type_converter< Host, Execution_Interface >::to_wasm ( bool && value)
inline

Definition at line 77 of file host_function.hpp.

77{ return value ? 1 : 0; }

◆ to_wasm() [3/4]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
no_match_t sysio::vm::type_converter< Host, Execution_Interface >::to_wasm ( T && )

◆ to_wasm() [4/4]

template<typename Host , typename Execution_Interface = execution_interface>
template<typename T >
no_match_t sysio::vm::type_converter< Host, Execution_Interface >::to_wasm ( T && )

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