diff options
| Commit | 6e19bb560d474736d45f5be011ff0830c7019991 (patch) | |
|---|---|---|
| Author | 2018-11-05 23:34:00 +0200 | |
| Committer | 2018-11-05 23:34:00 +0200 | |
| Files | 42d29cf1c4e6a535ba526f434debaac3a70df2c6 /src/frames.hpp | |
| IPL-6e19bb560d474736d45f5be011ff0830c7019991.tar IPL-6e19bb560d474736d45f5be011ff0830c7019991.tar.gz IPL-6e19bb560d474736d45f5be011ff0830c7019991.zip | ||
Squashed 'spasm/' content from commit 08ee95d
git-subtree-dir: spasm
git-subtree-split: 08ee95d89054ba0d33697d613799a0a013aedf89
1 files changed, 51 insertions, 0 deletions
| -rw-r--r-- | src/frames.hpp | 51 |
diff --git a/src/frames.hpp b/src/frames.hpp new file mode 100644 index 0000000..14d1d14 --- /dev/null +++ b/src/frames.hpp @@ -0,0 +1,51 @@ +#ifndef FRAMES_HPP +#define FRAMES_HPP + +#include <stack> + +#include "types.hpp" + +namespace SpasmImpl +{ +//! Class representing the stack frame for a function +/*! +** The class is implemented as a simple stack of frames while each frame +** is built up by a number of data_t objects +*/ +class FrameStack +{ + public: + FrameStack(); + FrameStack(const FrameStack&); + ~FrameStack(); + FrameStack& operator=(const FrameStack&); + + const data_t& operator[](size_t) const; + data_t& operator[](size_t); + void pop_frame(); + void new_frame(size_t); + bool empty() const; + + private: + //! pointer to the base of the stack + data_t* base_ptr; + + //! pointer to the beginning of the current frame + data_t* frame_ptr; + + //! size of the whole stack in data_t objects + size_t g_size; + + //! size of the current frame in data_t objects + size_t c_size; + + //! stack of the offsets between frames in the stack. + std::stack<size_t> fstack; + + void copy_fstack(const FrameStack&); + void delete_fstack(); +}; + +} // namespace SpasmImpl + +#endif // #ifndef FRAMES_HPP |
