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 | |
5b6cab1b |
23 | trace recheck => [ statement => [ |
24 | [ symbol => 'recheck' ], |
25 | @{$prop->for_deparse->[1]}, |
26 | ] ]; |
27 | |
614f3d93 |
28 | my $old_hyp = $old_ss->current_hypothesis; |
29 | |
30 | # we should probably be doing something about pruning the scope |
31 | # but that's completely pointless until we have rules (and also, |
32 | # the lock_to_depth arg needs to come from the proposition somehow) |
33 | |
34 | my $ap = DX::ActionPolicy::LockScope->new( |
35 | lock_to_depth => $old_hyp->scope->depth, |
36 | next_policy => $old_hyp->action_policy, |
37 | ); |
38 | |
39 | my $hyp = ref($old_hyp)->new( |
40 | scope => $old_hyp->scope, |
41 | resolved_propositions => DX::ResolvedPropositionSet->new_empty, |
42 | actions => [], |
43 | action_applications => [], |
44 | action_policy => $ap, |
45 | ); |
46 | |
47 | my $pseq = DX::PropositionSequence->new( |
48 | members => [ $prop ], |
49 | external_names => {}, |
50 | internal_names => {}, |
51 | ); |
52 | |
31753090 |
53 | my $next_step = (@rest |
54 | ? $self->but(proposition_list => \@rest) |
55 | : $self->on_completion_step); |
56 | |
614f3d93 |
57 | my $ss = DX::SearchState->new( |
58 | current_hypothesis => $hyp, |
df377b33 |
59 | adjustments_made => [], |
614f3d93 |
60 | propositions => $pseq, |
61 | next_step => DX::Step::ConsiderProposition->new( |
62 | proposition => $prop, |
63 | ), |
64 | is_solution_state => 0, |
251177ea |
65 | on_solution_step => DX::Step::CompleteRecheck->new( |
31753090 |
66 | resume_search_state => $old_ss->but(next_step => $next_step), |
251177ea |
67 | was_recheck_for => $prop, |
68 | ), |
7af7ed1e |
69 | on_exhaustion_step => DX::Step::FailRecheck->new( |
70 | resume_search_state => $old_ss->but(next_step => $self->on_failure_step), |
71 | ), |
614f3d93 |
72 | ); |
73 | |
74 | return $ss; |
75 | } |
76 | |
77 | 1; |