Convert run_job_list to tnode_T

This commit is contained in:
ridiculousfish 2018-01-15 16:08:06 -08:00
parent 4c93cece58
commit 5e4e0dab2c
2 changed files with 12 additions and 16 deletions

View File

@ -304,8 +304,8 @@ parse_execution_result_t parse_execution_context_t::run_if_statement(
} }
// Execute any job list we got. // Execute any job list we got.
if (job_list_to_execute != NULL) { if (job_list_to_execute) {
run_job_list(*job_list_to_execute, ib); run_job_list(job_list_to_execute, ib);
} else { } else {
// No job list means no sucessful conditions, so return 0 (issue #1443). // No job list means no sucessful conditions, so return 0 (issue #1443).
proc_set_last_status(STATUS_CMD_OK); proc_set_last_status(STATUS_CMD_OK);
@ -1274,21 +1274,16 @@ parse_execution_result_t parse_execution_context_t::run_1_job(tnode_t<g::job> jo
return parse_execution_success; return parse_execution_success;
} }
parse_execution_result_t parse_execution_context_t::run_job_list(const parse_node_t &job_list_node, template <typename Type>
parse_execution_result_t parse_execution_context_t::run_job_list(tnode_t<Type> job_list,
const block_t *associated_block) { const block_t *associated_block) {
assert(job_list_node.type == symbol_job_list || job_list_node.type == symbol_andor_job_list); static_assert(Type::token == symbol_job_list || Type::token == symbol_andor_job_list,
"Not a job list");
parse_execution_result_t result = parse_execution_success; parse_execution_result_t result = parse_execution_success;
const parse_node_t *job_list = &job_list_node; while (tnode_t<g::job> job = job_list.template next_in_list<g::job>()) {
while (job_list != NULL && !should_cancel_execution(associated_block)) { if (should_cancel_execution(associated_block)) break;
assert(job_list->type == symbol_job_list || job_list_node.type == symbol_andor_job_list); result = this->run_1_job(job, associated_block);
// Try pulling out a job.
const parse_node_t *job = tree().next_node_in_node_list(*job_list, symbol_job, &job_list);
if (job != NULL) {
result = this->run_1_job({&tree(), job}, associated_block);
}
} }
// Returns the last job executed. // Returns the last job executed.
@ -1327,7 +1322,7 @@ parse_execution_result_t parse_execution_context_t::eval_node_at_offset(
status = parse_execution_errored; status = parse_execution_errored;
} else { } else {
// No infinite recursion. // No infinite recursion.
status = this->run_job_list(node, associated_block); status = this->run_job_list(job_list, associated_block);
} }
break; break;
} }

View File

@ -119,7 +119,8 @@ class parse_execution_context_t {
io_chain_t *out_chain); io_chain_t *out_chain);
parse_execution_result_t run_1_job(tnode_t<grammar::job> job, const block_t *associated_block); parse_execution_result_t run_1_job(tnode_t<grammar::job> job, const block_t *associated_block);
parse_execution_result_t run_job_list(const parse_node_t &job_list_node, template <typename Type>
parse_execution_result_t run_job_list(tnode_t<Type> job_list_node,
const block_t *associated_block); const block_t *associated_block);
parse_execution_result_t populate_job_from_job_node(job_t *j, tnode_t<grammar::job> job_node, parse_execution_result_t populate_job_from_job_node(job_t *j, tnode_t<grammar::job> job_node,
const block_t *associated_block); const block_t *associated_block);