remove public is_in_loop api

master
Daniel Kolesa 2021-04-04 19:43:28 +02:00
parent 7158a6979b
commit 1624938c0b
3 changed files with 4 additions and 10 deletions

View File

@ -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);

View File

@ -243,7 +243,7 @@ state::state(alloc_func func, void *data) {
static_cast<command_impl *>(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<command_impl *>(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);
}

View File

@ -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"};