Adopt tnode_t in run_for_statement

This commit is contained in:
ridiculousfish 2018-01-14 01:47:09 -08:00
parent b23c6ebcba
commit ce173e86b5
2 changed files with 4 additions and 7 deletions

View file

@ -423,13 +423,10 @@ bool parse_execution_context_t::is_function_context() const {
} }
parse_execution_result_t parse_execution_context_t::run_for_statement( parse_execution_result_t parse_execution_context_t::run_for_statement(
const parse_node_t &header, const parse_node_t &block_contents) { tnode_t<grammar::for_header> header, tnode_t<grammar::job_list> block_contents) {
assert(header.type == symbol_for_header);
assert(block_contents.type == symbol_job_list);
// Get the variable name: `for var_name in ...`. We expand the variable name. It better result // Get the variable name: `for var_name in ...`. We expand the variable name. It better result
// in just one. // in just one.
const parse_node_t &var_name_node = *get_child(header, 1, parse_token_type_string); tnode_t<g::tok_string> var_name_node = header.child<1>();
wcstring for_var_name = get_source(var_name_node); wcstring for_var_name = get_source(var_name_node);
if (!expand_one(for_var_name, 0, NULL)) { if (!expand_one(for_var_name, 0, NULL)) {
report_error(var_name_node, FAILED_EXPANSION_VARIABLE_NAME_ERR_MSG, for_var_name.c_str()); report_error(var_name_node, FAILED_EXPANSION_VARIABLE_NAME_ERR_MSG, for_var_name.c_str());

View file

@ -95,8 +95,8 @@ class parse_execution_context_t {
// These encapsulate the actual logic of various (block) statements. // These encapsulate the actual logic of various (block) statements.
parse_execution_result_t run_block_statement(tnode_t<grammar::block_statement> statement); parse_execution_result_t run_block_statement(tnode_t<grammar::block_statement> statement);
parse_execution_result_t run_for_statement(const parse_node_t &header, parse_execution_result_t run_for_statement(tnode_t<grammar::for_header> header,
const parse_node_t &contents); tnode_t<grammar::job_list> contents);
parse_execution_result_t run_if_statement(const parse_node_t &statement); parse_execution_result_t run_if_statement(const parse_node_t &statement);
parse_execution_result_t run_switch_statement(const parse_node_t &statement); parse_execution_result_t run_switch_statement(const parse_node_t &statement);
parse_execution_result_t run_while_statement(const parse_node_t &header, parse_execution_result_t run_while_statement(const parse_node_t &header,