Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::vm::stack< ElemT, ElemSz, Allocator > Class Template Reference

#include <wasm_stack.hpp>

Public Member Functions

template<typename Alloc = Allocator, typename = std::enable_if_t<std::is_same_v<Alloc, std::nullptr_t>, int>>
 stack ()
 
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
 stack (Alloc &&alloc)
 
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
 stack (uint32_t n, Alloc &&alloc)
 
void push (ElemT &&e)
 
ElemT pop ()
 
ElemT & get (uint32_t index) const
 
void set (uint32_t index, const ElemT &el)
 
void eat (uint32_t index)
 
void compact (uint32_t index)
 
size_t current_index () const
 
ElemT & peek ()
 
const ElemT & peek () const
 
ElemT & peek (size_t i)
 
ElemT & get_back (size_t i)
 
const ElemT & get_back (size_t i) const
 
void trim (size_t amt)
 
size_t size () const
 
size_t capacity () const
 
template<typename Alloc = Allocator, typename = std::enable_if_t<std::is_same_v<Alloc, std::nullptr_t>, int>>
 stack ()
 
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
 stack (Alloc &&alloc)
 
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
 stack (uint32_t n, Alloc &&alloc)
 
void push (ElemT &&e)
 
ElemT pop ()
 
ElemT & get (uint32_t index) const
 
void set (uint32_t index, const ElemT &el)
 
void eat (uint32_t index)
 
void compact (uint32_t index)
 
size_t current_index () const
 
ElemT & peek ()
 
const ElemT & peek () const
 
ElemT & peek (size_t i)
 
ElemT & get_back (size_t i)
 
const ElemT & get_back (size_t i) const
 
void trim (size_t amt)
 
size_t size () const
 
size_t capacity () const
 

Detailed Description

template<typename ElemT, size_t ElemSz, typename Allocator = nullptr_t>
class sysio::vm::stack< ElemT, ElemSz, Allocator >

Definition at line 18 of file wasm_stack.hpp.

Constructor & Destructor Documentation

◆ stack() [1/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
template<typename Alloc = Allocator, typename = std::enable_if_t<std::is_same_v<Alloc, std::nullptr_t>, int>>
sysio::vm::stack< ElemT, ElemSz, Allocator >::stack ( )
inline

Definition at line 21 of file wasm_stack.hpp.

22 : _store(ElemSz) {}

◆ stack() [2/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
sysio::vm::stack< ElemT, ElemSz, Allocator >::stack ( Alloc && alloc)
inline

Definition at line 25 of file wasm_stack.hpp.

26 : _store(alloc, ElemSz) {}

◆ stack() [3/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
sysio::vm::stack< ElemT, ElemSz, Allocator >::stack ( uint32_t n,
Alloc && alloc )
inline

Definition at line 29 of file wasm_stack.hpp.

30 : _store(alloc, n) {}

◆ stack() [4/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
template<typename Alloc = Allocator, typename = std::enable_if_t<std::is_same_v<Alloc, std::nullptr_t>, int>>
sysio::vm::stack< ElemT, ElemSz, Allocator >::stack ( )
inline

Definition at line 21 of file wasm_stack.hpp.

22 : _store(ElemSz) {}

◆ stack() [5/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
sysio::vm::stack< ElemT, ElemSz, Allocator >::stack ( Alloc && alloc)
inline

Definition at line 25 of file wasm_stack.hpp.

26 : _store(alloc, ElemSz) {}

◆ stack() [6/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
template<typename Alloc = Allocator, typename = std::enable_if_t<!std::is_same_v<Alloc, nullptr_t>, int>>
sysio::vm::stack< ElemT, ElemSz, Allocator >::stack ( uint32_t n,
Alloc && alloc )
inline

Definition at line 29 of file wasm_stack.hpp.

30 : _store(alloc, n) {}

Member Function Documentation

◆ capacity() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
size_t sysio::vm::stack< ElemT, ElemSz, Allocator >::capacity ( ) const
inline

Definition at line 64 of file wasm_stack.hpp.

64{ return _store.size(); }

◆ capacity() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
size_t sysio::vm::stack< ElemT, ElemSz, Allocator >::capacity ( ) const
inline

Definition at line 64 of file wasm_stack.hpp.

64{ return _store.size(); }

◆ compact() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::compact ( uint32_t index)
inline

Definition at line 52 of file wasm_stack.hpp.

52 {
53 _store[index] = _store[_index-1];
54 _index = index+1;
55 }

◆ compact() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::compact ( uint32_t index)
inline

Definition at line 52 of file wasm_stack.hpp.

52 {
53 _store[index] = _store[_index-1];
54 _index = index+1;
55 }

◆ current_index() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
size_t sysio::vm::stack< ElemT, ElemSz, Allocator >::current_index ( ) const
inline

Definition at line 56 of file wasm_stack.hpp.

56{ return _index; }

◆ current_index() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
size_t sysio::vm::stack< ElemT, ElemSz, Allocator >::current_index ( ) const
inline

Definition at line 56 of file wasm_stack.hpp.

56{ return _index; }

◆ eat() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::eat ( uint32_t index)
inline

Definition at line 50 of file wasm_stack.hpp.

50{ _index = index; }

◆ eat() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::eat ( uint32_t index)
inline

Definition at line 50 of file wasm_stack.hpp.

50{ _index = index; }

◆ get() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::get ( uint32_t index) const
inline

Definition at line 42 of file wasm_stack.hpp.

42 {
43 SYS_VM_ASSERT(index <= _index, wasm_interpreter_exception, "invalid stack index");
44 return (ElemT&)_store[index];
45 }
#define SYS_VM_ASSERT(expr, exc_type, msg)
Definition exceptions.hpp:8

◆ get() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::get ( uint32_t index) const
inline

Definition at line 42 of file wasm_stack.hpp.

42 {
43 SYS_VM_ASSERT(index <= _index, wasm_interpreter_exception, "invalid stack index");
44 return (ElemT&)_store[index];
45 }

◆ get_back() [1/4]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::get_back ( size_t i)
inline

Definition at line 60 of file wasm_stack.hpp.

60{ return _store[_index - 1 - i]; }
Here is the caller graph for this function:

◆ get_back() [2/4]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::get_back ( size_t i)
inline

Definition at line 60 of file wasm_stack.hpp.

60{ return _store[_index - 1 - i]; }

◆ get_back() [3/4]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
const ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::get_back ( size_t i) const
inline

Definition at line 61 of file wasm_stack.hpp.

61{ return _store[_index - 1 - i]; }

◆ get_back() [4/4]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
const ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::get_back ( size_t i) const
inline

Definition at line 61 of file wasm_stack.hpp.

61{ return _store[_index - 1 - i]; }

◆ peek() [1/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::peek ( )
inline

Definition at line 57 of file wasm_stack.hpp.

57{ return _store[_index - 1]; }

◆ peek() [2/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::peek ( )
inline

Definition at line 57 of file wasm_stack.hpp.

57{ return _store[_index - 1]; }

◆ peek() [3/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
const ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::peek ( ) const
inline

Definition at line 58 of file wasm_stack.hpp.

58{ return _store[_index - 1]; }

◆ peek() [4/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
const ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::peek ( ) const
inline

Definition at line 58 of file wasm_stack.hpp.

58{ return _store[_index - 1]; }

◆ peek() [5/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::peek ( size_t i)
inline

Definition at line 59 of file wasm_stack.hpp.

59{ return _store[_index - 1 - i]; }

◆ peek() [6/6]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT & sysio::vm::stack< ElemT, ElemSz, Allocator >::peek ( size_t i)
inline

Definition at line 59 of file wasm_stack.hpp.

59{ return _store[_index - 1 - i]; }

◆ pop() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT sysio::vm::stack< ElemT, ElemSz, Allocator >::pop ( )
inline

Definition at line 40 of file wasm_stack.hpp.

40{ return _store[--_index]; }
Here is the caller graph for this function:

◆ pop() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
ElemT sysio::vm::stack< ElemT, ElemSz, Allocator >::pop ( )
inline

Definition at line 40 of file wasm_stack.hpp.

40{ return _store[--_index]; }

◆ push() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::push ( ElemT && e)
inline

Definition at line 32 of file wasm_stack.hpp.

32 {
33 if constexpr (std::is_same_v<Allocator, nullptr_t>) {
34 if (_index >= _store.size())
35 _store.resize(_store.size()*2);
36 }
37 _store[_index++] = std::forward<ElemT>(e);
38 }
Here is the caller graph for this function:

◆ push() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::push ( ElemT && e)
inline

Definition at line 32 of file wasm_stack.hpp.

32 {
33 if constexpr (std::is_same_v<Allocator, nullptr_t>) {
34 if (_index >= _store.size())
35 _store.resize(_store.size()*2);
36 }
37 _store[_index++] = std::forward<ElemT>(e);
38 }

◆ set() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::set ( uint32_t index,
const ElemT & el )
inline

Definition at line 46 of file wasm_stack.hpp.

46 {
47 SYS_VM_ASSERT(index <= _index, wasm_interpreter_exception, "invalid stack index");
48 _store[index] = el;
49 }

◆ set() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::set ( uint32_t index,
const ElemT & el )
inline

Definition at line 46 of file wasm_stack.hpp.

46 {
47 SYS_VM_ASSERT(index <= _index, wasm_interpreter_exception, "invalid stack index");
48 _store[index] = el;
49 }

◆ size() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
size_t sysio::vm::stack< ElemT, ElemSz, Allocator >::size ( ) const
inline

Definition at line 63 of file wasm_stack.hpp.

63{ return _index; }

◆ size() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
size_t sysio::vm::stack< ElemT, ElemSz, Allocator >::size ( ) const
inline

Definition at line 63 of file wasm_stack.hpp.

63{ return _index; }

◆ trim() [1/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::trim ( size_t amt)
inline

Definition at line 62 of file wasm_stack.hpp.

62{ _index -= amt; }
Here is the caller graph for this function:

◆ trim() [2/2]

template<typename ElemT , size_t ElemSz, typename Allocator = nullptr_t>
void sysio::vm::stack< ElemT, ElemSz, Allocator >::trim ( size_t amt)
inline

Definition at line 62 of file wasm_stack.hpp.

62{ _index -= amt; }

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