From: Matt S Trout Date: Sun, 10 Jul 2016 14:04:20 +0000 (+0000) Subject: further threading of SearchState through ResolveProposition X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ac94761d17d91e89f39bc6d6f9977dd1d2ec865;hp=310662b5561b21ba1ec8c9857672f866342a9845;p=scpubgit%2FDX.git further threading of SearchState through ResolveProposition --- diff --git a/lib/DX/Step/ResolveProposition.pm b/lib/DX/Step/ResolveProposition.pm index 3728a63..d92ac24 100644 --- a/lib/DX/Step/ResolveProposition.pm +++ b/lib/DX/Step/ResolveProposition.pm @@ -29,8 +29,9 @@ sub apply_to { my $old_hyp = $ss->current_hypothesis; trace 'step.apply.old_hyp '.$self => $old_hyp; trace 'step.apply.actions '.$self => $self->actions; - my $new_hyp = $self->_apply_to_hyp($old_hyp); - return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_hyp; + my $new_ss = $self->_apply_to_ss($ss); + return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss; + my $new_hyp = $new_ss->current_hypothesis; trace 'step.apply.new_hyp '.$self => $new_hyp; my $ns = do { if (my $prop = $ss->next_proposition($new_hyp)) { @@ -54,27 +55,33 @@ sub apply_to { ); } -sub _apply_to_hyp { - my ($self, $old_hyp) = @_; +sub _apply_to_ss { + my ($self, $old_ss) = @_; + my $old_hyp = $old_ss->current_hypothesis; (my $hyp, my @recheck) = $old_hyp->with_resolution( $self->resolves, $self->depends_on, $self->actions ); - return $self->_recheck_hyp_for($hyp, @recheck); + return undef unless $hyp; + return $self->_recheck_for( + $old_ss->but(current_hypothesis => $hyp), + @recheck + ); } -sub _recheck_hyp_for { - my ($self, $old_hyp, @recheck) = @_; - return undef unless $old_hyp; - return $old_hyp unless @recheck; - my $hyp = $old_hyp; +sub _recheck_for { + my ($self, $old_ss, @recheck) = @_; + return $old_ss unless @recheck; + my $ss = $old_ss; foreach my $prop (@recheck) { - return undef unless $hyp = $self->_recheck_one($hyp, $prop); + return undef unless $ss = $self->_recheck_one($ss, $prop); } - return $hyp; + return $ss; } sub _recheck_one { - my ($self, $old_hyp, $prop) = @_; + my ($self, $old_ss, $prop) = @_; + + my $old_hyp = $old_ss->current_hypothesis; my $ap = DX::ActionPolicy::LockScope->new( lock_to_depth => $old_hyp->scope->depth, @@ -133,7 +140,9 @@ sub _recheck_one { trace 'step.recheck.done' => 'yay'; - return $old_hyp->but(resolved_propositions => $rps); + return $old_ss->but( + current_hypothesis => $old_hyp->but(resolved_propositions => $rps), + ); } 1;