예제 #1
0
static void insert_enforcers(slice_index si, stip_structure_traversal *st)
{
  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  stip_traverse_structure_children(si,st);

  {
    stip_deep_copies_type copies;
    stip_structure_traversal st_nested;

    slice_index const * const threat_start = st->param;
    slice_index const threat_start_tester = SLICE_TESTER(*threat_start);

    assert(*threat_start!=no_slice);
    assert(threat_start_tester!=no_slice);
    assert(SLICE_TYPE(threat_start_tester)==STThreatStart);

    {
      slice_index const prototype = alloc_pipe(STThreatDefeatedTester);
      attack_branch_insert_slices(threat_start_tester,&prototype,1);
    }

    init_deep_copy(&st_nested,st,&copies);
    stip_structure_traversal_override_single(&st_nested,
                                             STThreatDefeatedTester,
                                             &move_and_stop_copying);
    stip_structure_traversal_override_by_contextual(&st_nested,
                                                    slice_contextual_conditional_pipe,
                                                    &copy_shallow);
    stip_structure_traversal_override_by_contextual(&st_nested,
                                                    slice_contextual_testing_pipe,
                                                    &copy_shallow);
    stip_traverse_structure(threat_start_tester,&st_nested);

    SLICE_NEXT2(si) = copies[threat_start_tester];
  }

  {
    /* if the threats are short, max_unsolvable might interfere with enforcing
     * them */
    slice_index const prototype = alloc_reset_unsolvable_slice();
    attack_branch_insert_slices(SLICE_NEXT2(si),&prototype,1);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #2
0
static void insert_solvers(slice_index si, stip_structure_traversal *st)
{
  slice_index const * const threat_start = st->param;
  stip_deep_copies_type copies;
  stip_structure_traversal st_nested;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  stip_traverse_structure_children(si,st);

  init_deep_copy(&st_nested,st,&copies);
  stip_structure_traversal_override_single(&st_nested,
                                           STThreatEnd,
                                           &end_copying);
  stip_structure_traversal_override_by_contextual(&st_nested,
                                                  slice_contextual_conditional_pipe,
                                                  &copy_shallow);
  stip_structure_traversal_override_by_contextual(&st_nested,
                                                  slice_contextual_testing_pipe,
                                                  &copy_shallow);
  stip_traverse_structure(*threat_start,&st_nested);

  SLICE_NEXT2(si) = alloc_proxy_slice();
  link_to_branch(SLICE_NEXT2(si),copies[*threat_start]);

  {
    slice_index const prototypes[] = {
        alloc_pipe(STDummyMove),
        alloc_defense_played_slice(),
        alloc_pipe(STThreatCollector)
    };
    defense_branch_insert_slices_behind_proxy(SLICE_NEXT2(si),prototypes,3,si);
  }

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}
예제 #3
0
파일: mummer.c 프로젝트: Die9teWoge/popeye
static void spin_off_measuring_branch(slice_index si, stip_structure_traversal *st)
{
  instrumentation_state_type const * const state = st->param;

  stip_deep_copies_type copies;
  stip_structure_traversal st_nested;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%u",si);
  TraceFunctionParamListEnd();

  if (SLICE_NEXT2(si)==no_slice)
  {
    SLICE_NEXT2(si) = alloc_proxy_slice();

    init_deep_copy(&st_nested,st,&copies);
    stip_structure_traversal_override_single(&st_nested,
                                             STMummerDeadend,
                                             &stop_copying);
    stip_structure_traversal_override_single(&st_nested,
                                             STRestartGuard,
                                             &skip_copying);
    stip_structure_traversal_override_single(&st_nested,
                                             STDeadEndGoal,
                                             &skip_copying);
    stip_structure_traversal_override_single(&st_nested,
                                             STGoalReachableGuardFilterMate,
                                             &skip_copying);
    stip_structure_traversal_override_single(&st_nested,
                                             STGoalReachableGuardFilterStalemate,
                                             &skip_copying);
    stip_structure_traversal_override_single(&st_nested,
                                             STGoalReachableGuardFilterProof,
                                             &skip_copying);
    stip_structure_traversal_override_single(&st_nested,
                                             STGoalReachableGuardFilterProofFairy,
                                             &skip_copying);
    stip_structure_traversal_override_by_function(&st_nested,
                                                  slice_function_move_removing_optimiser,
                                                  &skip_copying);
    if (mummer_strictness[state->current_side]!=mummer_strictness_regular)
    {
      stip_structure_traversal_override_single(&st_nested,
                                               STEndOfBranchGoal,
                                               &skip_copying);
      stip_structure_traversal_override_single(&st_nested,
                                               STSelfCheckGuard,
                                               &skip_copying);
    }
    else
    {
      regular_deep_copy_end_of_branch_goal = st_nested.map.visitors[STEndOfBranchGoal];
      stip_structure_traversal_override_single(&st_nested,
                                               STEndOfBranchGoal,
                                               &copy_end_of_branch_goal_if_necessary);
      stip_structure_traversal_override_single(&st_nested,
                                               STEndOfBranchGoalImmobile,
                                               &copy_end_of_branch_goal_if_necessary);
    }

    stip_traverse_structure(SLICE_NEXT1(si),&st_nested);

    link_to_branch(SLICE_NEXT2(si),copies[SLICE_NEXT1(si)]);

    {
      slice_index const prototype = alloc_pipe(STMummerBookkeeper);
      switch (st->context)
      {
        case stip_traversal_context_attack:
          attack_branch_insert_slices_behind_proxy(SLICE_NEXT2(si),&prototype,1,si);
          break;

        case stip_traversal_context_defense:
          defense_branch_insert_slices_behind_proxy(SLICE_NEXT2(si),&prototype,1,si);
          break;

        case stip_traversal_context_help:
          help_branch_insert_slices_behind_proxy(SLICE_NEXT2(si),&prototype,1,si);
          break;

        default:
          assert(0);
          break;
      }
    }

    if (mummer_strictness[state->current_side]!=mummer_strictness_regular)
    {
      slice_index const prototype = alloc_pipe(STUltraMummerMeasurerDeadend);
      slice_insertion_insert_contextually(copies[SLICE_NEXT1(si)],st->context,&prototype,1);
    }
  }

  stip_traverse_structure_children(si,st);

  TraceFunctionExit(__func__);
  TraceFunctionResultEnd();
}