-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.hpp
More file actions
37 lines (28 loc) · 776 Bytes
/
stack.hpp
File metadata and controls
37 lines (28 loc) · 776 Bytes
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
#pragma once
#include "types.hpp"
#include <cstddef>
#include <vector>
struct Stack {
static constexpr std::size_t MAX_ADDRESS = 1048576; // 4mb, (word-size: 4 byte)
int_type data[MAX_ADDRESS + 1];
int_type* SP;
int_type* HP;
struct HeapData {
int_type address;
int_type size;
};
std::vector<HeapData> heapEntries;
Stack();
void push(int_type value);
int_type pop();
int_type load(int_type address);
void store(int_type address, int_type value);
void dup();
void reserveStackSpace(int_type size);
void removeStackSpace(int_type size);
int_type reserveHeapSpace(int_type size);
void removeHeapSpace(int_type address);
int_type resizeHeapSpace(int_type address, int_type new_size);
bool isEmpty() const;
void reset();
};