From: Matt S Trout Date: Sun, 19 Jun 2016 17:52:44 +0000 (+0000) Subject: steps now operate on search states X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=110fd00291e5e8ae2f7f1bccde19307b5bba118a;p=scpubgit%2FDX.git steps now operate on search states --- diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm index d29dc09..d119d9b 100644 --- a/lib/DX/SearchState.pm +++ b/lib/DX/SearchState.pm @@ -37,7 +37,8 @@ sub with_one_step { my $hyp = $self->current_hypothesis; return undef unless my $step = $self->next_step; my ($first_alt, @rest_alt) = my @alt = @{$self->alternatives}; - my ($new_hyp, $alt_step) = $step->apply_to($hyp); + my ($new_ss, $alt_step) = $step->apply_to($self); + my $new_hyp = ($new_ss ? $new_ss->current_hypothesis : undef); if ($new_hyp) { return $self->but( current_hypothesis => $new_hyp, diff --git a/lib/DX/Step/InvokeNextPredicate.pm b/lib/DX/Step/InvokeNextPredicate.pm index 510d013..3e969e9 100644 --- a/lib/DX/Step/InvokeNextPredicate.pm +++ b/lib/DX/Step/InvokeNextPredicate.pm @@ -7,7 +7,8 @@ with 'DX::Role::Step'; has proposition => (is => 'ro', required => 1); sub apply_to { - my ($self, $hyp) = @_; + my ($self, $ss) = @_; + my $hyp = $ss->current_hypothesis; return (undef, $self->proposition->resolve_for($hyp->scope)); } diff --git a/lib/DX/Step/Normal.pm b/lib/DX/Step/Normal.pm index d5bb1e3..350d4dc 100644 --- a/lib/DX/Step/Normal.pm +++ b/lib/DX/Step/Normal.pm @@ -25,13 +25,14 @@ sub but_with_dependencies_on { } sub apply_to { - my ($self, $old_hyp) = @_; + my ($self, $ss) = @_; + 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 (undef, $self->alternative_step) unless $new_hyp; trace 'step.apply.new_hyp '.$self => $new_hyp; - return ($new_hyp, $self->alternative_step); + return ($ss->but(current_hypothesis => $new_hyp), $self->alternative_step); } sub _apply_to_hyp {