Commit | Line | Data |
614f3d93 |
1 | package DX::Step::EnterRecheck; |
2 | |
251177ea |
3 | use DX::Step::CompleteRecheck; |
7af7ed1e |
4 | use DX::Step::FailRecheck; |
251177ea |
5 | |
614f3d93 |
6 | use DX::Class; |
7 | |
8 | with 'DX::Role::Step'; |
9 | |
d6fabec9 |
10 | has proposition_list => ( |
11 | is => 'ro', isa => PropositionList, required => 1 |
12 | ); |
614f3d93 |
13 | |
d6fabec9 |
14 | has on_completion_step => (is => 'ro', isa => Step, required => 1); |
91543b62 |
15 | |
d6fabec9 |
16 | has on_failure_step => (is => 'ro', isa => Maybe[Step], required => 1); |
7af7ed1e |
17 | |
614f3d93 |
18 | sub apply_to { |
19 | my ($self, $old_ss) = @_; |
20 | |
21 | my ($prop, @rest) = @{$self->proposition_list}; |
22 | |
614f3d93 |
23 | my $old_hyp = $old_ss->current_hypothesis; |
24 | |
25 | # we should probably be doing something about pruning the scope |
26 | # but that's completely pointless until we have rules (and also, |
27 | # the lock_to_depth arg needs to come from the proposition somehow) |
28 | |
29 | my $ap = DX::ActionPolicy::LockScope->new( |
30 | lock_to_depth => $old_hyp->scope->depth, |
31 | next_policy => $old_hyp->action_policy, |
32 | ); |
33 | |
34 | my $hyp = ref($old_hyp)->new( |
35 | scope => $old_hyp->scope, |
36 | resolved_propositions => DX::ResolvedPropositionSet->new_empty, |
37 | actions => [], |
38 | action_applications => [], |
39 | action_policy => $ap, |
40 | ); |
41 | |
42 | my $pseq = DX::PropositionSequence->new( |
43 | members => [ $prop ], |
44 | external_names => {}, |
45 | internal_names => {}, |
46 | ); |
47 | |
31753090 |
48 | my $next_step = (@rest |
49 | ? $self->but(proposition_list => \@rest) |
50 | : $self->on_completion_step); |
51 | |
614f3d93 |
52 | my $ss = DX::SearchState->new( |
53 | current_hypothesis => $hyp, |
df377b33 |
54 | adjustments_made => [], |
614f3d93 |
55 | propositions => $pseq, |
56 | next_step => DX::Step::ConsiderProposition->new( |
57 | proposition => $prop, |
58 | ), |
59 | is_solution_state => 0, |
251177ea |
60 | on_solution_step => DX::Step::CompleteRecheck->new( |
31753090 |
61 | resume_search_state => $old_ss->but(next_step => $next_step), |
251177ea |
62 | was_recheck_for => $prop, |
63 | ), |
7af7ed1e |
64 | on_exhaustion_step => DX::Step::FailRecheck->new( |
65 | resume_search_state => $old_ss->but(next_step => $self->on_failure_step), |
66 | ), |
614f3d93 |
67 | ); |
68 | |
69 | return $ss; |
70 | } |
71 | |
72 | 1; |