Website Summary Files Commits Branches @commit @diff @stats
path: root / spasm / src / dstack.hpp
diff options
context:
space:
mode:
Commitc3252e63c296d1133254f4973fe7e3bf52cc6c1a (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-11-05 23:34:00 +0200
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-11-05 23:34:00 +0200
Files67c6bfc067696562aded70f66d25899f3f70a1c8 /spasm/src/dstack.hpp
IPL-c3252e63c296d1133254f4973fe7e3bf52cc6c1a.tar
IPL-c3252e63c296d1133254f4973fe7e3bf52cc6c1a.tar.gz
IPL-c3252e63c296d1133254f4973fe7e3bf52cc6c1a.zip
Parentc9912fdb174e1580629e00cacab6bc4ed480e643 (diff)
Parent6e19bb560d474736d45f5be011ff0830c7019991 (diff)
Merge commit '6e19bb560d474736d45f5be011ff0830c7019991' as 'spasm'
1 files changed, 46 insertions, 0 deletions
-rw-r--r--spasm/src/dstack.hpp46
diff --git a/spasm/src/dstack.hpp b/spasm/src/dstack.hpp
new file mode 100644
index 0000000..850b66b
--- /dev/null
+++ b/spasm/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