From 6f99c9a904f2951087984c996fc9af4258fd7e66 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 14 Jan 2018 02:45:27 -0800 Subject: [PATCH] Adopt tnode_t in run_function_statement --- src/parse_execution.cpp | 12 +++++------- src/parse_execution.h | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 8fbd1b89d..921faf829 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -343,10 +343,7 @@ parse_execution_result_t parse_execution_context_t::run_begin_statement( // Define a function. parse_execution_result_t parse_execution_context_t::run_function_statement( - const parse_node_t &header, const parse_node_t &block_end_command) { - assert(header.type == symbol_function_header); - assert(block_end_command.type == symbol_end_command); - + tnode_t header, tnode_t block_end_command) { // Get arguments. wcstring_list_t argument_list; parse_execution_result_t result = this->determine_arguments(header, &argument_list, failglob); @@ -358,9 +355,10 @@ parse_execution_result_t parse_execution_context_t::run_function_statement( // The function definition extends from the end of the header to the function end. It's not // just the range of the contents because that loses comments - see issue #1710. assert(block_end_command.has_source()); - size_t contents_start = header.source_start + header.source_length; - size_t contents_end = - block_end_command.source_start; // 1 past the last character in the function definition + auto header_range = header.source_range(); + size_t contents_start = header_range->start + header_range->length; + size_t contents_end = block_end_command.source_range() + ->start; // 1 past the last character in the function definition assert(contents_end >= contents_start); // Swallow whitespace at both ends. diff --git a/src/parse_execution.h b/src/parse_execution.h index 929b19a15..5ef894d03 100644 --- a/src/parse_execution.h +++ b/src/parse_execution.h @@ -101,8 +101,8 @@ class parse_execution_context_t { parse_execution_result_t run_switch_statement(tnode_t statement); parse_execution_result_t run_while_statement(tnode_t statement, tnode_t contents); - parse_execution_result_t run_function_statement(const parse_node_t &header, - const parse_node_t &block_end_command); + parse_execution_result_t run_function_statement(tnode_t header, + tnode_t block_end); parse_execution_result_t run_begin_statement(const parse_node_t &header, const parse_node_t &contents);