forked from KPGPMC/furlang
feat(furvm): add a thing
This commit is contained in:
@@ -17,4 +17,34 @@ std::shared_ptr<executor> executor::create(const std::shared_ptr<context>& conte
|
||||
return std::move(ex);
|
||||
}
|
||||
|
||||
void executor::push_frame(const std::shared_ptr<mod>& mod, std::size_t position) {
|
||||
m_frames.emplace((struct executor::frame){ mod, position, m_stack.size() });
|
||||
}
|
||||
|
||||
struct executor::frame executor::pop_frame() {
|
||||
struct executor::frame frame = m_frames.top();
|
||||
m_frames.pop();
|
||||
return frame;
|
||||
}
|
||||
|
||||
struct executor::frame executor::frame() const {
|
||||
return m_frames.top();
|
||||
}
|
||||
|
||||
void executor::push_thing(const std::shared_ptr<class thing>& thing) {
|
||||
m_stack.push(thing);
|
||||
}
|
||||
|
||||
std::shared_ptr<class thing> executor::pop_thing() {
|
||||
if (m_frames.top().stackBase >= m_stack.size()) return {};
|
||||
std::shared_ptr<class thing> top = std::move(m_stack.top());
|
||||
m_stack.pop();
|
||||
return top;
|
||||
}
|
||||
|
||||
std::shared_ptr<class thing> executor::thing() const {
|
||||
if (m_frames.top().stackBase >= m_stack.size()) return {};
|
||||
return m_stack.top();
|
||||
}
|
||||
|
||||
} // namespace furvm
|
||||
Reference in New Issue
Block a user