Skip to content

Commit 02c7d6f

Browse files
authored
[#113] feat: add DaedalusVm::top_is_reference
1 parent 8c4edf7 commit 02c7d6f

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

include/zenkit/DaedalusVm.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ namespace zenkit {
331331
[[nodiscard]] ZKAPI std::string const& pop_string();
332332
[[nodiscard]] ZKAPI std::tuple<DaedalusSymbol*, std::uint8_t, std::shared_ptr<DaedalusInstance>>
333333
pop_reference();
334+
[[nodiscard]] ZKAPI bool top_is_reference() const;
334335

335336
/// \brief Registers a Daedalus external function.
336337
///

src/DaedalusVm.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,14 @@ namespace zenkit {
587587
return {std::get<DaedalusSymbol*>(v.value), v.index, v.context};
588588
}
589589

590+
bool DaedalusVm::top_is_reference() const {
591+
if (_m_stack_ptr == 0) {
592+
throw DaedalusVmException {"popping from empty stack"};
593+
}
594+
595+
return _m_stack[_m_stack_ptr - 1].reference;
596+
}
597+
590598
std::shared_ptr<DaedalusInstance> DaedalusVm::pop_instance() {
591599
if (_m_stack_ptr == 0) {
592600
throw DaedalusVmException {"popping instance from empty stack"};

0 commit comments

Comments
 (0)