7#include <sysio/vm/backend.hpp>
8#include <sysio/vm/host_function.hpp>
10namespace sysio {
namespace chain {
namespace webassembly {
12 template <
typename T, std::
size_t A>
16 template <
typename T, std::
size_t A>
23 std::is_same_v<T, float32_t> || std::is_same_v<T, float64_t> || std::is_same_v<T, float128_t>;
31 static constexpr bool value = std::is_same_v<float128_t, T> ||
32 std::is_same_v<null_terminated_ptr, T> ||
33 std::is_same_v<memcpy_params, T> ||
34 std::is_same_v<memcmp_params, T> ||
35 std::is_same_v<memset_params, T> ||
36 std::is_same_v<decltype(is_legacy_ptr(std::declval<T>())), std::true_type> ||
37 std::is_same_v<decltype(is_legacy_span(std::declval<T>())), std::true_type> ||
38 std::is_same_v<name, T> ||
39 std::is_arithmetic_v<T>;
45 !(std::is_pointer_v<T> || std::is_reference_v<T>);
52 static constexpr bool value = std::is_same_v<std::remove_const_t<T>,
char>;
66 template <
typename... Ts>
69 template <
typename T,
typename U>
70 inline static bool is_aliasing(
const T& s1,
const U& s2) {
71 std::uintptr_t a_begin =
reinterpret_cast<std::uintptr_t
>(s1.data());
72 std::uintptr_t a_end = a_begin + s1.size_bytes();
74 std::uintptr_t b_begin =
reinterpret_cast<std::uintptr_t
>(s2.data());
75 std::uintptr_t b_end = b_begin + s2.size_bytes();
79 if (a_begin > b_begin) {
89 if (std::min(a_end, b_end) == b_begin)
95 inline static bool is_nan(
const float32_t f ) {
98 inline static bool is_nan(
const float64_t f ) {
107 SYS_ASSERT(ctx.get_host().get_context().is_context_free(), unaccessible_api,
"this API may only be called from context_free apply");
112 SYS_ASSERT(!ctx.get_host().get_context().is_context_free(), unaccessible_api,
"only context free api's can be used in this context");
117 SYS_ASSERT(ctx.get_host().get_context().is_privileged(), unaccessible_api,
118 "${code} does not have permission to call this API", (
"code", ctx.get_host().get_context().get_receiver()));
124 return {
static_cast<const char*
>(val.get_original_pointer()),
sizeof(
T)};
134 using arg_t = std::decay_t<
decltype(arg)>;
135 static_assert( is_whitelisted_type_v<arg_t>,
"whitelisted type violation");
136 if constexpr (is_span_type_v<arg_t> || vm::is_argument_proxy_type_v<arg_t>) {
138 using nested_arg_t = std::decay_t<
decltype(narg)>;
139 if constexpr (sysio::vm::is_span_type_v<nested_arg_t> || vm::is_argument_proxy_type_v<nested_arg_t>)
147 std::is_same_v<T, float32_t> || std::is_same_v<T, float64_t> || std::is_same_v<T, float128_t>;
153 template<
typename T, std::
size_t A>
167 static_assert( are_whitelisted_legacy_types_v<std::decay_t<
decltype(args)>...>,
"legacy whitelisted type violation");
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
void swap(picojson::value &x, picojson::value &y)
constexpr bool is_softfloat_type_v
constexpr bool is_wasm_arithmetic_type_v
constexpr std::integral_constant< bool, A !=0 > is_legacy_ptr(legacy_ptr< T, A >)
constexpr std::integral_constant< bool, A !=0 > is_legacy_span(legacy_span< T, A >)
vm::span< const char > to_span(const vm::argument_proxy< T * > &val)
constexpr bool should_check_nan_v
key Invalid authority Invalid transaction Invalid block ID Invalid packed transaction Invalid chain ID Invalid symbol Signature type is not a currently activated type Block can not be found Unlinkable block Block does not guarantee concurrent execution without conflicts Block exhausted allowed resources Block is from the future Block is not signed by expected producer Block includes an ill formed protocol feature activation extension Block includes an ill formed additional block signature extension Error decompressing transaction Transaction should have at least one required authority Expired Transaction Invalid Reference Block Duplicate deferred transaction The transaction can not be found Transaction is too big Invalid transaction extension Transaction includes disallowed Transaction exceeded transient resource limit Account name already exists sysio_assert_message assertion failure Action can not be found Attempt to use unaccessible API Inline Action exceeds maximum size limit sysio_assert_code assertion failure uses restricted error code value action return value size too big Permission Query Exception Contract Table Query Exception Database is an unknown or unsupported version Database usage is at unsafe levels wasm_exception
key Invalid authority Invalid transaction Invalid block ID Invalid packed transaction Invalid chain ID Invalid symbol Signature type is not a currently activated type Block can not be found Unlinkable block Block does not guarantee concurrent execution without conflicts Block exhausted allowed resources Block is from the future Block is not signed by expected producer Block includes an ill formed protocol feature activation extension Block includes an ill formed additional block signature extension transaction_exception
void invoke_on(F &&func, const Args &... args)
#define T(meth, val, expected)
bool f128_is_nan(const float128_t &f)
bool f64_is_nan(const float64_t f)
bool f32_is_nan(const float32_t f)
static constexpr bool value
static constexpr bool value
#define SYS_VM_PRECONDITION(NAME,...)
#define SYS_VM_INVOKE_ONCE(CONDITION)
#define SYS_VM_INVOKE_ON_ALL(CONDITION)