Switching symbol_job to use tnode_t in parse_execution.cpp

This commit is contained in:
ridiculousfish 2018-01-14 01:26:28 -08:00
parent 4768c42f5d
commit cdc0167ba1
2 changed files with 7 additions and 8 deletions

View File

@ -106,10 +106,8 @@ node_offset_t parse_execution_context_t::get_offset(const parse_node_t &node) co
return offset; return offset;
} }
tnode_t<grammar::plain_statement> tnode_t<g::plain_statement> parse_execution_context_t::infinite_recursive_statement_in_job_list(
parse_execution_context_t::infinite_recursive_statement_in_job_list(const parse_node_t &job_list, tnode_t<g::job_list> job_list, wcstring *out_func_name) const {
wcstring *out_func_name) const {
assert(job_list.type == symbol_job_list);
// This is a bit fragile. It is a test to see if we are inside of function call, but not inside // This is a bit fragile. It is a test to see if we are inside of function call, but not inside
// a block in that function call. If, in the future, the rules for what block scopes are pushed // a block in that function call. If, in the future, the rules for what block scopes are pushed
// on function invocation changes, then this check will break. // on function invocation changes, then this check will break.
@ -127,8 +125,8 @@ parse_execution_context_t::infinite_recursive_statement_in_job_list(const parse_
const wcstring &forbidden_function_name = parser->forbidden_function.back(); const wcstring &forbidden_function_name = parser->forbidden_function.back();
// Get the first job in the job list. // Get the first job in the job list.
const parse_node_t *first_job = tree().next_node_in_node_list(job_list, symbol_job, NULL); auto first_job = job_list.next_in_list<g::job>();
if (first_job == NULL) { if (!first_job) {
return {}; return {};
} }
@ -1380,9 +1378,10 @@ parse_execution_result_t parse_execution_context_t::eval_node_at_offset(
// the entry point for both top-level execution (the first node) and INTERNAL_BLOCK_NODE // the entry point for both top-level execution (the first node) and INTERNAL_BLOCK_NODE
// execution (which does block statements, but never job lists). // execution (which does block statements, but never job lists).
assert(offset == 0); assert(offset == 0);
tnode_t<g::job_list> job_list{&tree(), &node};
wcstring func_name; wcstring func_name;
auto infinite_recursive_node = auto infinite_recursive_node =
this->infinite_recursive_statement_in_job_list(node, &func_name); this->infinite_recursive_statement_in_job_list(job_list, &func_name);
if (infinite_recursive_node) { if (infinite_recursive_node) {
// We have an infinite recursion. // We have an infinite recursion.
this->report_error(infinite_recursive_node, INFINITE_FUNC_RECURSION_ERR_MSG, this->report_error(infinite_recursive_node, INFINITE_FUNC_RECURSION_ERR_MSG,

View File

@ -74,7 +74,7 @@ class parse_execution_context_t {
parse_token_type_t expected_type = token_type_invalid) const; parse_token_type_t expected_type = token_type_invalid) const;
node_offset_t get_offset(const parse_node_t &node) const; node_offset_t get_offset(const parse_node_t &node) const;
tnode_t<grammar::plain_statement> infinite_recursive_statement_in_job_list( tnode_t<grammar::plain_statement> infinite_recursive_statement_in_job_list(
const parse_node_t &job_list, wcstring *out_func_name) const; tnode_t<grammar::job_list> job_list, wcstring *out_func_name) const;
bool is_function_context() const; bool is_function_context() const;
/// Indicates whether a job is a simple block (one block, no redirections). /// Indicates whether a job is a simple block (one block, no redirections).