feat(furvm): expose the stack
This commit is contained in:
@@ -150,6 +150,8 @@ public:
|
|||||||
thing<>& top_thing();
|
thing<>& top_thing();
|
||||||
|
|
||||||
const thing<>& top_thing() const;
|
const thing<>& top_thing() const;
|
||||||
|
|
||||||
|
const std::vector<thing<>>& stack() const { return m_stack; }
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Stores a thing in a frame variable.
|
* @brief Stores a thing in a frame variable.
|
||||||
@@ -191,8 +193,8 @@ private:
|
|||||||
executor_flags m_flags = executor_flags::Done;
|
executor_flags m_flags = executor_flags::Done;
|
||||||
context* m_context;
|
context* m_context;
|
||||||
|
|
||||||
std::stack<frame> m_frames;
|
std::stack<frame> m_frames;
|
||||||
std::stack<thing<>> m_stack;
|
std::vector<thing<>> m_stack;
|
||||||
|
|
||||||
new_frame_callback m_newFrameCb = nullptr;
|
new_frame_callback m_newFrameCb = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -140,28 +140,28 @@ struct executor::frame executor::top_frame() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
thing<>& executor::push_thing(thing<>&& thing) {
|
thing<>& executor::push_thing(thing<>&& thing) {
|
||||||
return m_stack.emplace(std::move(thing));
|
return m_stack.emplace_back(std::move(thing));
|
||||||
}
|
}
|
||||||
|
|
||||||
thing<>& executor::push_thing(const thing<>& thing) {
|
thing<>& executor::push_thing(const thing<>& thing) {
|
||||||
return m_stack.emplace(thing);
|
return m_stack.emplace_back(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
thing<> executor::pop_thing() {
|
thing<> executor::pop_thing() {
|
||||||
if (m_frames.top().stackBase >= m_stack.size()) throw stack_underflow();
|
if (m_frames.top().stackBase >= m_stack.size()) throw stack_underflow();
|
||||||
auto top = std::move(m_stack.top());
|
auto top = std::move(m_stack.back());
|
||||||
m_stack.pop();
|
m_stack.pop_back();
|
||||||
return std::move(top);
|
return std::move(top);
|
||||||
}
|
}
|
||||||
|
|
||||||
thing<>& executor::top_thing() {
|
thing<>& executor::top_thing() {
|
||||||
if (m_frames.top().stackBase >= m_stack.size()) throw stack_underflow();
|
if (m_frames.top().stackBase >= m_stack.size()) throw stack_underflow();
|
||||||
return m_stack.top();
|
return m_stack.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
const thing<>& executor::top_thing() const {
|
const thing<>& executor::top_thing() const {
|
||||||
if (m_frames.top().stackBase >= m_stack.size()) throw stack_underflow();
|
if (m_frames.top().stackBase >= m_stack.size()) throw stack_underflow();
|
||||||
return m_stack.top();
|
return m_stack.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void executor::store_thing(variable_t variable, const thing<>& thing) {
|
void executor::store_thing(variable_t variable, const thing<>& thing) {
|
||||||
|
|||||||
Reference in New Issue
Block a user