3#include <sysio/vm/utils.hpp>
8#define SYS_VM_ASSERT( expr, exc_type, msg ) \
9 if (!UNLIKELY(expr)) { \
10 throw exc_type{msg}; \
13namespace sysio {
namespace vm {
14 struct exception :
public std::exception {
15 virtual const char*
what()
const throw()=0;
16 virtual const
char*
detail()const throw()=0;
20#define DECLARE_EXCEPTION(name, _code, _what) \
21 struct name : public sysio::vm::exception { \
22 name(std::string msg) : msg(msg) {} \
23 virtual const char* what()const throw() { return _what; } \
24 virtual const char* detail()const throw() { return msg.c_str(); } \
25 uint32_t code()const { return _code; } \
29namespace sysio {
namespace vm {
30 DECLARE_EXCEPTION( wasm_interpreter_exception, 4000000,
"wasm interpreter exception" )
31 DECLARE_EXCEPTION( wasm_section_length_exception, 4000001,
"wasm section length exception" )
34 DECLARE_EXCEPTION( wasm_vector_oob_exception, 4000004,
"wasm vector out of bounds" )
35 DECLARE_EXCEPTION( wasm_unsupported_import_exception, 4000005,
"wasm interpreter only accepts function imports" )
48#undef DECLARE_EXCEPTION
virtual const char * what() const =0
#define DECLARE_EXCEPTION(name, _code, _what)