Beispiel #1
0
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);
}
Beispiel #2
0
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);
}
Beispiel #3
0
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);
}