Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
parser.hpp File Reference
#include <sysio/vm/allocator.hpp>
#include <sysio/vm/constants.hpp>
#include <sysio/vm/exceptions.hpp>
#include <sysio/vm/leb128.hpp>
#include <sysio/vm/options.hpp>
#include <sysio/vm/sections.hpp>
#include <sysio/vm/types.hpp>
#include <sysio/vm/utils.hpp>
#include <sysio/vm/vector.hpp>
#include <sysio/vm/debug_info.hpp>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <utility>
#include <variant>
#include <vector>
Include dependency graph for parser.hpp:

Go to the source code of this file.

Classes

struct  sysio::vm::detail::max_mutable_globals_checker< Options, Enable >
 
struct  sysio::vm::detail::max_mutable_globals_checker< Options, std::void_t< max_mutable_globals_t< Options > > >
 
struct  sysio::vm::detail::max_func_local_bytes_checker< Options, Enable >
 
struct  sysio::vm::detail::max_func_local_bytes_checker< Options, std::void_t< decltype(std::declval< Options >().max_func_local_bytes)> >
 
struct  sysio::vm::detail::max_func_local_bytes_stack_checker< Options, Enable >
 
struct  sysio::vm::detail::max_func_local_bytes_stack_checker< Options, std::enable_if_t<!max_func_local_bytes_checker< Options >::is_defined||get_max_func_local_bytes_no_stack_c< Options >(0)> >
 
struct  sysio::vm::detail::sysio_max_nested_structures_checker< Options, Enable >
 
struct  sysio::vm::detail::sysio_max_nested_structures_checker< Options, std::void_t< decltype(std::declval< Options >().sysio_max_nested_structures)> >
 
class  sysio::vm::binary_parser< Writer, Options, DebugInfo >
 
struct  sysio::vm::binary_parser< Writer, Options, DebugInfo >::pc_element_t
 
struct  sysio::vm::binary_parser< Writer, Options, DebugInfo >::operand_stack_type_tracker
 
struct  sysio::vm::binary_parser< Writer, Options, DebugInfo >::local_types_t
 

Namespaces

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

Macros

#define PARSER_OPTION(name, default_, type)
 
#define MAX_ELEMENTS(name, default_)
 
#define LOAD_OP(op_name, max_align, type)
 
#define STORE_OP(op_name, max_align, type)
 
#define UNOP(opname)
 
#define BINOP(opname)
 
#define CASTOP(dst, opname, src)
 
#define R   i32
 
#define A   i32
 
#define A   i64
 
#define A   f32
 
#define A   f64
 
#define R   A
 
#define A   i32
 
#define A   i64
 
#define A   f32
 
#define A   f64
 

Typedefs

template<typename Options >
using sysio::vm::detail::max_mutable_globals_t = decltype(std::declval<Options>().max_mutable_global_bytes)
 

Functions

 sysio::vm::detail::PARSER_OPTION (max_func_local_bytes_flags, max_func_local_bytes_flags_t::locals|max_func_local_bytes_flags_t::stack, max_func_local_bytes_flags_t)
 
template<typename Options >
constexpr auto sysio::vm::detail::get_max_func_local_bytes_no_stack_c (int) -> std::enable_if_t< std::is_pointer_v< decltype(&Options::max_func_local_bytes_flags)>, bool >
 
template<typename Options >
constexpr auto sysio::vm::detail::get_max_func_local_bytes_no_stack_c (long) -> bool
 
 sysio::vm::detail::PARSER_OPTION (forbid_export_mutable_globals, false, bool)
 
 sysio::vm::detail::PARSER_OPTION (allow_code_after_function_end, false, bool)
 
 sysio::vm::detail::PARSER_OPTION (allow_u32_limits_flags, false, bool)
 
 sysio::vm::detail::PARSER_OPTION (allow_invalid_empty_local_set, false, bool)
 
 sysio::vm::detail::PARSER_OPTION (parse_custom_section_name, false, bool)
 

Macro Definition Documentation

◆ A [1/8]

#define A   i32

◆ A [2/8]

#define A   i64

◆ A [3/8]

#define A   f32

◆ A [4/8]

#define A   f64

◆ A [5/8]

#define A   i32

◆ A [6/8]

#define A   i64

◆ A [7/8]

#define A   f32

◆ A [8/8]

#define A   f64

◆ BINOP

#define BINOP ( opname)
Value:
case opcodes::opname: check_in_bounds(); code_writer.emit_ ## opname(); op_stack.pop(types::A); op_stack.pop(types::A); op_stack.push(types::R); break;

◆ CASTOP

#define CASTOP ( dst,
opname,
src )
Value:
case opcodes::dst ## _ ## opname ## _ ## src: check_in_bounds(); code_writer.emit_ ## dst ## _ ## opname ## _ ## src(); op_stack.pop(types::src); op_stack.push(types::dst); break;

◆ LOAD_OP

#define LOAD_OP ( op_name,
max_align,
type )
Value:
case opcodes::op_name: { \
check_in_bounds(); \
SYS_VM_ASSERT(_mod->memories.size() > 0, wasm_parse_exception, "load requires memory"); \
uint32_t alignment = parse_varuint32(code); \
uint32_t offset = parse_varuint32(code); \
SYS_VM_ASSERT(alignment <= uint32_t(max_align), wasm_parse_exception, "alignment cannot be greater than size."); \
SYS_VM_ASSERT(offset <= detail::get_max_memory_offset(_options), wasm_parse_exception, "load offset too large."); \
op_stack.pop(types::i32); \
op_stack.push(types::type); \
code_writer.emit_ ## op_name( alignment, offset ); \
} break;
unsigned int uint32_t
Definition stdint.h:126

◆ MAX_ELEMENTS

#define MAX_ELEMENTS ( name,
default_ )
Value:
PARSER_OPTION(name, default_, std::uint32_t)
std::string name
#define PARSER_OPTION(name, default_, type)
Definition parser.hpp:56

Definition at line 66 of file parser.hpp.

66#define MAX_ELEMENTS(name, default_)\
67 PARSER_OPTION(name, default_, std::uint32_t)

◆ PARSER_OPTION

#define PARSER_OPTION ( name,
default_,
type )
Value:
template<typename Options> \
type get_ ## name(const Options& options, long) { (void)options; return default_; } \
template<typename Options> \
auto get_ ## name(const Options& options, int) -> decltype(options.name) { \
return options.name; \
} \
template<typename Options> \
type get_ ## name(const Options& options) { return detail::get_ ## name(options, 0); }

Definition at line 56 of file parser.hpp.

56#define PARSER_OPTION(name, default_, type) \
57 template<typename Options> \
58 type get_ ## name(const Options& options, long) { (void)options; return default_; } \
59 template<typename Options> \
60 auto get_ ## name(const Options& options, int) -> decltype(options.name) { \
61 return options.name; \
62 } \
63 template<typename Options> \
64 type get_ ## name(const Options& options) { return detail::get_ ## name(options, 0); }

◆ R [1/2]

#define R   i32

◆ R [2/2]

#define R   A

◆ STORE_OP

#define STORE_OP ( op_name,
max_align,
type )
Value:
case opcodes::op_name: { \
check_in_bounds(); \
SYS_VM_ASSERT(_mod->memories.size() > 0, wasm_parse_exception, "store requires memory"); \
uint32_t alignment = parse_varuint32(code); \
uint32_t offset = parse_varuint32(code); \
SYS_VM_ASSERT(alignment <= uint32_t(max_align), wasm_parse_exception, "alignment cannot be greater than size."); \
SYS_VM_ASSERT(offset <= detail::get_max_memory_offset(_options), wasm_parse_exception, "store offset too large."); \
op_stack.pop(types::type); \
op_stack.pop(types::i32); \
code_writer.emit_ ## op_name( alignment, offset ); \
} break;

◆ UNOP

#define UNOP ( opname)
Value:
case opcodes::opname: check_in_bounds(); code_writer.emit_ ## opname(); op_stack.pop(types::A); op_stack.push(types::R); break;