From: Matt S Trout Date: Sat, 2 Apr 2016 20:49:18 +0000 (+0000) Subject: add propositions method to searchstate X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1350f664522bba79100b5316f9850325369a5571;p=scpubgit%2FDX.git add propositions method to searchstate --- diff --git a/lib/DX/Hypothesis.pm b/lib/DX/Hypothesis.pm index 59e0480..e8b66c0 100644 --- a/lib/DX/Hypothesis.pm +++ b/lib/DX/Hypothesis.pm @@ -63,9 +63,15 @@ sub but_recheck_for { action_policy => $ap, ); + my $pseq = DX::PropositionSequence->new( + members => \@recheck, + external_names => {}, + internal_names => {}, + ); + trace 'step.recheck.hyp' => $hyp; - my $ss = DX::SearchState->new_for($hyp); + my $ss = DX::SearchState->new_for($hyp, $pseq); my $sol_ss = $ss->find_solution; diff --git a/lib/DX/QueryState.pm b/lib/DX/QueryState.pm index f7c030a..e4438d7 100644 --- a/lib/DX/QueryState.pm +++ b/lib/DX/QueryState.pm @@ -55,7 +55,7 @@ sub new_search_state_for { action_applications => [], action_policy => DX::ActionPolicy::Allow->new, ); - return DX::SearchState->new_for($hyp); + return DX::SearchState->new_for($hyp, $prop_seq); } sub with_additional_proposition { diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm index 38271b3..def236d 100644 --- a/lib/DX/SearchState.pm +++ b/lib/DX/SearchState.pm @@ -8,18 +8,21 @@ has current_hypothesis => (is => 'ro', isa => Hypothesis, required => 1); has next_step => (is => 'ro', isa => Maybe[Step]); +has propositions => (is => 'ro', isa => PropositionSequence, required => 1); + has alternatives => (is => 'ro', isa => AlternativeList, required => 1); sub next_proposition { $_[0]->current_hypothesis->head_proposition } sub new_for { - my ($class, $hyp) = @_; + my ($class, $hyp, $props) = @_; $class->new( current_hypothesis => $hyp, alternatives => [], next_step => DX::Step::InvokeNextPredicate->new( proposition => $hyp->head_proposition, ), + propositions => $props, ); } @@ -72,7 +75,8 @@ sub force_backtrack { return ref($self)->new( current_hypothesis => $first_alt->[0], next_step => $first_alt->[1], - alternatives => \@rest_alt + alternatives => \@rest_alt, + propositions => $self->propositions, ); }