From 6e19bb560d474736d45f5be011ff0830c7019991 Mon Sep 17 00:00:00 2001 From: Dimitar Trendafilov Date: Mon, 5 Nov 2018 23:34:00 +0200 Subject: Squashed 'spasm/' content from commit 08ee95d git-subtree-dir: spasm git-subtree-split: 08ee95d89054ba0d33697d613799a0a013aedf89 --- src/dstack.hpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/dstack.hpp (limited to 'src/dstack.hpp') diff --git a/src/dstack.hpp b/src/dstack.hpp new file mode 100644 index 0000000..850b66b --- /dev/null +++ b/src/dstack.hpp @@ -0,0 +1,46 @@ +#ifndef DSTACK_HPP +#define DSTACK_HPP + +#include "types.hpp" + +namespace SpasmImpl +{ +//! class representing the data stack + +/*! The class is quite simple stack. It is byte-orientatied - every push +** and pop is done in bytes with no taking care of any byte order! +*/ +class Dstack +{ + public: + Dstack(); + Dstack(const Dstack&); + Dstack& operator=(const Dstack&); + ~Dstack(); + void push(data_t); + void push(byte*, size_t); + void pop(void*, size_t); + data_t pop(); + data_t top() const; + + void reserve(size_t); + void strip_memory(); + size_t size() const; + size_t reserved() const; + bool empty() const; + + private: + void copy_dstack(const Dstack&); + + //! pointer to the bottom of the stack + byte* bottom; + + //! pointer to the top of the stack + byte* tos; + + //! size of the stack in bytes + size_t s_size; +}; +} // namespace SpasmImpl + +#endif // #ifndef DSTACK_HPP -- cgit v1.3.1-23-gd82d