void finish_for_loop(Term* forTerm) { Branch* contents = nested_contents(forTerm); // Add a 'loop_output' term that will collect each iteration's output. Term* loopOutput = apply(contents, FUNCS.loop_output, TermList(loop_get_primary_result(contents))); // Add a primary output apply(contents, FUNCS.output, TermList(loopOutput)); // pack_any_open_state_vars(contents); for_loop_fix_state_input(contents); check_to_add_state_output_placeholder(contents); add_implicit_placeholders(forTerm); repoint_terms_to_use_input_placeholders(contents); check_to_insert_implicit_inputs(forTerm); update_extra_outputs(forTerm); loop_update_exit_points(contents); set_branch_in_progress(contents, false); }
void finish_for_loop(Term* forTerm) { Branch* contents = nested_contents(forTerm); // Need to finish here to prevent error branch_finish_changes(contents); // Add a a primary output Term* primaryOutput = apply(contents, FUNCS.output, TermList(loop_get_primary_result(contents))); primaryOutput->setBoolProp("accumulatingOutput", true); respecialize_type(primaryOutput); // pack_any_open_state_vars(contents); for_loop_fix_state_input(contents); check_to_add_state_output_placeholder(contents); add_implicit_placeholders(forTerm); repoint_terms_to_use_input_placeholders(contents); check_to_insert_implicit_inputs(forTerm); update_extra_outputs(forTerm); branch_finish_changes(contents); }
void finish_if_block(Term* ifBlock) { Branch* contents = nested_contents(ifBlock); // Make sure there is a primary output if (get_output_placeholder(contents, 0) == NULL) if_block_prepend_primary_output(ifBlock); if_block_normalize_state_inputs(ifBlock); int caseIndex = 0; for (CaseIterator it(contents); it.unfinished(); it.advance()) { Term* term = it.current(); if_block_turn_outer_name_rebinds_into_outputs(ifBlock, nested_contents(term)); if_block_fix_outer_pointers(ifBlock, nested_contents(term)); modify_branch_so_that_state_access_is_indexed(nested_contents(term), caseIndex); caseIndex++; } if_block_turn_common_rebinds_into_outputs(ifBlock); if_block_update_output_placeholder_types_from_cases(ifBlock); check_to_insert_implicit_inputs(ifBlock); update_extra_outputs(ifBlock); }
void finish_while_loop(Block* block) { block_finish_changes(block); // Add a a primary output apply(block, FUNCS.output, TermList(NULL)); // Add looped_inputs insert_looped_placeholders(block); update_extra_outputs(block->owningTerm, block); update_for_control_flow(block); block_finish_changes(block); }
void finish_for_loop(Term* forTerm) { Block* block = nested_contents(forTerm); // Need to finish here to prevent error block_finish_changes(block); Term* primaryResult = loop_get_primary_result(block); Term* iterator = loop_find_iterator(block); Term* nextCall = apply_dynamic_method(block, s_advance, TermList(iterator)); hide_from_source(nextCall); // Add a a primary output Term* primaryOutput = apply(block, FUNCS.output, TermList(primaryResult)); primaryOutput->setBoolProp(s_AccumulatingOutput, true); // TODO: can delete? respecialize_type(primaryOutput); insert_looped_placeholders(block); update_extra_outputs(forTerm, block); block_finish_changes(block); }