From cdc0167ba1fd2c2db84d75ff80e8e037c81f1d3e Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 14 Jan 2018 01:26:28 -0800 Subject: [PATCH] Switching symbol_job to use tnode_t in parse_execution.cpp --- src/parse_execution.cpp | 13 ++++++------- src/parse_execution.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 53ffab53d..4f0b94a26 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -106,10 +106,8 @@ node_offset_t parse_execution_context_t::get_offset(const parse_node_t &node) co return offset; } -tnode_t -parse_execution_context_t::infinite_recursive_statement_in_job_list(const parse_node_t &job_list, - wcstring *out_func_name) const { - assert(job_list.type == symbol_job_list); +tnode_t parse_execution_context_t::infinite_recursive_statement_in_job_list( + tnode_t job_list, wcstring *out_func_name) const { // 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 // 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(); // 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); - if (first_job == NULL) { + auto first_job = job_list.next_in_list(); + if (!first_job) { 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 // execution (which does block statements, but never job lists). assert(offset == 0); + tnode_t job_list{&tree(), &node}; wcstring func_name; 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) { // We have an infinite recursion. this->report_error(infinite_recursive_node, INFINITE_FUNC_RECURSION_ERR_MSG, diff --git a/src/parse_execution.h b/src/parse_execution.h index 6b785473e..f9ee352ff 100644 --- a/src/parse_execution.h +++ b/src/parse_execution.h @@ -74,7 +74,7 @@ class parse_execution_context_t { parse_token_type_t expected_type = token_type_invalid) const; node_offset_t get_offset(const parse_node_t &node) const; tnode_t infinite_recursive_statement_in_job_list( - const parse_node_t &job_list, wcstring *out_func_name) const; + tnode_t job_list, wcstring *out_func_name) const; bool is_function_context() const; /// Indicates whether a job is a simple block (one block, no redirections).