1 package DX::Step::ResolveProposition;
3 use DX::Step::EnterRecheck;
4 use DX::Step::Backtrack;
6 use DX::Utils qw(expand_deps);
10 with 'DX::Role::Step';
12 has resolution_space => (is => 'ro', isa => ResolutionSpace);
14 sub resolves { shift->resolution_space->proposition }
16 sub current_resolution { shift->resolution_space->next_resolution }
18 sub actions { shift->current_resolution->actions }
20 sub depends_on { shift->current_resolution->veracity_depends_on }
23 my ($self, @actions) = @_;
24 $self->but(actions => [ @actions, @{$self->actions} ]);
27 sub but_with_dependencies_on {
28 my ($self, @deps) = @_;
29 $self->but(depends_on => [ @{$self->depends_on}, @deps ]);
33 my ($self, $old_ss) = @_;
34 trace resolve => [ statement => [
35 [ symbol => 'resolve' ],
38 [ symbol => 'proposition' ],
39 @{$self->resolves->for_deparse->[1]},
43 [ symbol => 'actions' ],
44 [ block => $self->actions ],
48 [ symbol => 'depends_on' ],
51 [ symbol => (split '::', ${$_->[0]})[-1] ],
52 [ value_path => [ @{$_}[1..$#$_] ] ]
53 ] ], @{$self->depends_on}
59 if (my $prop = $old_ss->next_proposition) {
60 DX::Step::ConsiderProposition->new(
64 $old_ss->on_solution_step
67 my $ss = $old_ss->but(
70 [ $self->resolution_space, $old_ss ],
71 @{$old_ss->decisions_taken}
74 my $new_ss = $self->_apply_to_ss($ss);
75 return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
80 my ($self, $old_ss) = @_;
81 my $old_hyp = $old_ss->current_hypothesis;
82 (my $hyp, my @recheck) = $old_hyp->with_resolution(
83 $self->resolves, $self->depends_on, $self->actions
85 return undef unless $hyp;
86 return $self->_recheck_for(
87 $old_ss->but(current_hypothesis => $hyp),
93 my ($self, $old_ss, @recheck) = @_;
95 return $old_ss unless @recheck;
97 my $ss = $old_ss->but(
98 next_step => DX::Step::EnterRecheck->new(
99 proposition_list => \@recheck,
100 on_completion_step => $old_ss->next_step,
101 on_failure_step => DX::Step::Backtrack->new,