Eliminate job_should_be_backgrounded

This commit is contained in:
ridiculousfish 2018-01-15 16:39:27 -08:00
parent 3e7e92dfff
commit d7c28c9316
4 changed files with 10 additions and 11 deletions

View File

@ -1196,7 +1196,7 @@ parse_execution_result_t parse_execution_context_t::run_1_job(tnode_t<g::job> jo
(job_control_mode == JOB_CONTROL_ALL) ||
((job_control_mode == JOB_CONTROL_INTERACTIVE) && shell_is_interactive()));
job->set_flag(JOB_FOREGROUND, !tree().job_should_be_backgrounded(job_node));
job->set_flag(JOB_FOREGROUND, !job_node_is_background(job_node));
job->set_flag(JOB_TERMINAL, job->get_flag(JOB_CONTROL) && !is_event);

View File

@ -1405,12 +1405,6 @@ parse_node_tree_t::parse_node_list_t parse_node_tree_t::comment_nodes_for_node(
return result;
}
bool parse_node_tree_t::job_should_be_backgrounded(const parse_node_t &job) const {
assert(job.type == symbol_job);
const parse_node_t *opt_background = get_child(job, 2, symbol_optional_background);
return opt_background != NULL && opt_background->tag == parse_background;
}
const parse_node_t *parse_node_tree_t::next_node_in_node_list(
const parse_node_t &node_list, parse_token_type_t entry_type,
const parse_node_t **out_list_tail) const {
@ -1465,3 +1459,8 @@ arguments_node_list_t get_argument_nodes(tnode_t<grammar::argument_list> list) {
arguments_node_list_t get_argument_nodes(tnode_t<grammar::arguments_or_redirections_list> list) {
return list.descendants<grammar::argument>();
}
bool job_node_is_background(tnode_t<grammar::job> job) {
tnode_t<grammar::optional_background> bg = job.child<2>();
return bg.tag() == parse_background;
}

View File

@ -214,9 +214,6 @@ class parse_node_tree_t : public std::vector<parse_node_t> {
/// Given a node, return all of its comment nodes.
parse_node_list_t comment_nodes_for_node(const parse_node_t &node) const;
/// Given a job, return whether it should be backgrounded, because it has a & specifier.
bool job_should_be_backgrounded(const parse_node_t &job) const;
private:
// Finds the last node of a given type underneath a given node, or NULL if it could not be
// found. If parent is NULL, this finds the last node in the tree of that type.
@ -437,6 +434,9 @@ using arguments_node_list_t = std::vector<tnode_t<grammar::argument>>;
arguments_node_list_t get_argument_nodes(tnode_t<grammar::argument_list>);
arguments_node_list_t get_argument_nodes(tnode_t<grammar::arguments_or_redirections_list>);
/// Return whether the given job is background because it has a & symbol.
bool job_node_is_background(tnode_t<grammar::job>);
/// The big entry point. Parse a string, attempting to produce a tree for the given goal type.
bool parse_tree_from_string(const wcstring &str, parse_tree_flags_t flags,
parse_node_tree_t *output, parse_error_list_t *errors,

View File

@ -1163,7 +1163,7 @@ parser_test_error_bits_t parse_util_detect_errors(const wcstring &buff_src,
// while foo & ; end
// If it's not a background job, nothing to do.
auto job = tnode_t<grammar::job>{&node_tree, &node};
if (node_tree.job_should_be_backgrounded(job)) {
if (job_node_is_background(job)) {
errored |= detect_errors_in_backgrounded_job(node_tree, job, &parse_errors);
}
} else if (node.type == symbol_plain_statement) {