MCPcopy Create free account
hub / github.com/covscript/covscript / foreach_helper

Function foreach_helper

sources/instance/statement.cpp:680–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678
679 template <typename T, typename X>
680 void foreach_helper(const context_t &context, const var_id &iterator, const var &obj,
681 std::deque<statement_base *> &body)
682 {
683 if (obj.const_val<T>().empty())
684 return;
685 if (context->instance->break_block)
686 context->instance->break_block = false;
687 if (context->instance->continue_block)
688 context->instance->continue_block = false;
689 scope_guard scope(context);
690 for (const X &it : obj.const_val<T>()) {
691 current_process->poll_event();
692 context->instance->storage.add_var_no_return(iterator, it);
693 for (auto &ptr : body) {
694 try {
695 ptr->run();
696 }
697 catch (const cs::exception &e) {
698 throw e;
699 }
700 catch (const std::exception &e) {
701 throw exception(ptr->get_line_num(), ptr->get_file_path(), ptr->get_raw_code(), e.what());
702 }
703 if (context->instance->return_fcall) {
704 return;
705 }
706 if (context->instance->break_block) {
707 context->instance->break_block = false;
708 return;
709 }
710 if (context->instance->continue_block) {
711 context->instance->continue_block = false;
712 break;
713 }
714 }
715 scope.clear();
716 }
717 }
718
719 void statement_foreach::run_impl()
720 {

Callers

nothing calls this directly

Calls 8

poll_eventMethod · 0.80
add_var_no_returnMethod · 0.80
exceptionFunction · 0.70
emptyMethod · 0.45
runMethod · 0.45
get_line_numMethod · 0.45
whatMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected