Website Summary Files Commits Branches @commit @diff @stats
path: root / spasm / src / dstack.hpp
blob: 850b66b39e0ae9ba8211bc187d6d42452181ef88 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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