X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDX%2FQueryState.pm;h=b37878328ed98cccaf0ba25f883579518b781b11;hb=2548ce615db02d9ebd44d15359c1220aaf06798f;hp=b15ac83b96a17ce3c7c480eee67ed4fd87018b14;hpb=5f12a9d8e45505cd07c13eb83cde76dddc25fe1c;p=scpubgit%2FDX.git diff --git a/lib/DX/QueryState.pm b/lib/DX/QueryState.pm index b15ac83..b378783 100644 --- a/lib/DX/QueryState.pm +++ b/lib/DX/QueryState.pm @@ -1,9 +1,8 @@ package DX::QueryState; -use Types::Standard qw(HashRef); use DX::Scope; use DX::Hypothesis; -use DX::SearchState; +use DX::SearchProcess; use DX::ResolvedPropositionSet; use DX::Value::Unset; use DX::ActionBuilder::UnsetValue; @@ -35,26 +34,25 @@ sub new_search_state_for { locals => [ dict( map +($_ => DX::Value::Unset->new( - identity_path => [ 0, $_ ], action_builder => DX::ActionBuilder::UnsetValue->new( target_path => [ 0, $_ ], ) ) ), @local_names ) - ] + ], + lex_map => { + map +($_ => [ 0, $_ ]), @local_names + } ); my $hyp = DX::Hypothesis->new( scope => $scope, resolved_propositions => DX::ResolvedPropositionSet->new_empty, - outstanding_propositions => $prop_seq->members, actions => [], + action_applications => [], action_policy => DX::ActionPolicy::Allow->new, ); - return DX::SearchState->new( - current_hypothesis => $hyp, - alternatives => [], - ); + return DX::SearchProcess->new_for($hyp, $prop_seq); } sub with_additional_proposition { @@ -63,11 +61,18 @@ sub with_additional_proposition { ->with_additional_proposition($prop); my $sol_ss = $self->new_search_state_for($prop_seq) ->find_solution; - die "No solution" unless $sol_ss; + die "No solution\n" unless $sol_ss; $self->but( proposition_sequence => $prop_seq, search_state => $sol_ss, ); } +sub with_forced_backtrack { + my ($self) = @_; + my $next_ss = $self->search_state->find_next_solution; + die "No next solution\n" unless $next_ss; + $self->but(search_state => $next_ss); +} + 1;