Just forked your branch to snoop around.
I was thinking about implementing a STOP operator to halt script execution. You’d have to interrupt the run_script loop to do so:
process_result_t run_script(size_t script_no) {
process_result_t result = {.has_value = false, .value = 0 };
exec_state_t es;
es_init(&es);
for (size_t i = 0; i < tele_get_script_l(script_no); i++) {
result = process(&es, tele_get_script_c(script_no, i));
if (result.value == MAGIC_STOP_NUMBER)
return result;
}
return result;
}
Which comes from process():
if (cs_stack_size(&cs)) {
process_result_t o = {.has_value = true, .value = cs_pop(&cs) };
return o;
}
else {
process_result_t o = {.has_value = false, .value = 0 };
return o;
}
As far as I can tell, nothing cares about the final return value for the command state stack, which makes sense, as there is nothing more to consume the value at the end of the command.
Would it be safe to use a magic number here? What is the scope of the .value returned from any of the current operators, i.e.: is there a safe magic number?
I’ll keep familiarizing myself with the operators to try to grok the situation, but some of the bounds are going to be elusive.