diff --git a/include/cubescript/cubescript.hh b/include/cubescript/cubescript.hh index d700566..29e06fb 100644 --- a/include/cubescript/cubescript.hh +++ b/include/cubescript/cubescript.hh @@ -404,8 +404,6 @@ struct LIBCUBESCRIPT_EXPORT state { loop_state run_loop(bcode_ref const &code, any_value &ret); loop_state run_loop(bcode_ref const &code); - bool is_in_loop() const; - bool get_override_mode() const; bool set_override_mode(bool v); diff --git a/src/cs_state.cc b/src/cs_state.cc index 5c1e180..2fb6ce8 100644 --- a/src/cs_state.cc +++ b/src/cs_state.cc @@ -243,7 +243,7 @@ state::state(alloc_func func, void *data) { static_cast(p)->p_type = ID_LOCAL; p = new_command("break", "", [](auto &cs, auto, auto &) { - if (cs.is_in_loop()) { + if (cs.thread_pointer()->loop_level) { throw break_exception{}; } else { throw error{cs, "no loop to break"}; @@ -252,7 +252,7 @@ state::state(alloc_func func, void *data) { static_cast(p)->p_type = ID_BREAK; p = new_command("continue", "", [](auto &cs, auto, auto &) { - if (cs.is_in_loop()) { + if (cs.thread_pointer()->loop_level) { throw continue_exception{}; } else { throw error{cs, "no loop to continue"}; @@ -828,10 +828,6 @@ LIBCUBESCRIPT_EXPORT loop_state state::run_loop(bcode_ref const &code) { return run_loop(code, ret); } -LIBCUBESCRIPT_EXPORT bool state::is_in_loop() const { - return !!p_tstate->loop_level; -} - LIBCUBESCRIPT_EXPORT bool state::get_override_mode() const { return (p_tstate->ident_flags & IDENT_FLAG_OVERRIDDEN); } diff --git a/src/cs_vm.cc b/src/cs_vm.cc index 598e00e..4c4bbef 100644 --- a/src/cs_vm.cc +++ b/src/cs_vm.cc @@ -638,14 +638,14 @@ std::uint32_t *vm_exec( continue; } case BC_INST_BREAK | BC_INST_FLAG_FALSE: - if (cs.is_in_loop()) { + if (ts.loop_level) { throw break_exception(); } else { throw error{cs, "no loop to break"}; } break; case BC_INST_BREAK | BC_INST_FLAG_TRUE: - if (cs.is_in_loop()) { + if (ts.loop_level) { throw continue_exception(); } else { throw error{cs, "no loop to continue"};