From: Matt S Trout Date: Sat, 31 Mar 2018 18:59:13 +0000 (+0000) Subject: switch over to storing rspace+ss as decision list X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1c02730b4c397d64a0ee1b2efe1bbf30626791ed;p=scpubgit%2FDX.git switch over to storing rspace+ss as decision list --- diff --git a/lib/DX/SearchProcess.pm b/lib/DX/SearchProcess.pm index e2ec2d5..e22eaa3 100644 --- a/lib/DX/SearchProcess.pm +++ b/lib/DX/SearchProcess.pm @@ -6,7 +6,7 @@ use DX::Class; has current_search_state => ( is => 'ro', isa => SearchState, required => 1, handles => [ qw( - current_hypothesis next_step propositions adjustments_made + current_hypothesis next_step propositions ) ], ); diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm index bb0cb10..8b08596 100644 --- a/lib/DX/SearchState.pm +++ b/lib/DX/SearchState.pm @@ -12,7 +12,7 @@ has next_step => (is => 'ro', isa => Maybe[Step], required => 1); has propositions => (is => 'ro', isa => PropositionSequence, required => 1); -has adjustments_made => (is => 'ro', isa => AdjustmentList, required => 1); +has decisions_taken => (is => 'ro', isa => DecisionList, required => 1); has is_solution_state => (is => 'ro', isa => Bool, required => 1); @@ -32,7 +32,7 @@ sub new_for { my ($class, $hyp, $props) = @_; $class->new( current_hypothesis => $hyp, - adjustments_made => [], + decisions_taken => [], propositions => $props, (@{$props->members} ? ( diff --git a/lib/DX/Step/Backtrack.pm b/lib/DX/Step/Backtrack.pm index d14ca2f..f693c49 100644 --- a/lib/DX/Step/Backtrack.pm +++ b/lib/DX/Step/Backtrack.pm @@ -7,11 +7,11 @@ with 'DX::Role::Step'; sub apply_to { my ($self, $ss) = @_; trace backtrack => [ statement => [ [ symbol => 'backtrack' ] ] ]; - foreach my $adj (@{$ss->adjustments_made}) { - my ($step_was, $ss_was) = @$adj; - if (my $alt = $step_was->alternative_step) { - return $ss_was->but(next_step => $alt); - } + foreach my $adj (@{$ss->decisions_taken}) { + my ($rspace_was, $ss_was) = @$adj; + return $ss_was->but( + next_step => $rspace_was->remaining_resolution_space->next_step + ); } return $ss->but(next_step => $ss->on_exhaustion_step); } diff --git a/lib/DX/Step/EnterRecheck.pm b/lib/DX/Step/EnterRecheck.pm index f0fffd1..d2d44ba 100644 --- a/lib/DX/Step/EnterRecheck.pm +++ b/lib/DX/Step/EnterRecheck.pm @@ -57,7 +57,7 @@ sub apply_to { my $ss = DX::SearchState->new( current_hypothesis => $hyp, - adjustments_made => [], + decisions_taken => [], propositions => $pseq, next_step => DX::Step::ConsiderProposition->new( proposition => $prop, diff --git a/lib/DX/Step/ResolveProposition.pm b/lib/DX/Step/ResolveProposition.pm index 3416c27..42b92dc 100644 --- a/lib/DX/Step/ResolveProposition.pm +++ b/lib/DX/Step/ResolveProposition.pm @@ -93,13 +93,10 @@ sub apply_to { }; my $ss = $old_ss->but( next_step => $ns, - (@{$self->actions} - ? (adjustments_made => [ - [ $self, $old_ss ], - @{$old_ss->adjustments_made} - ]) - : () - ), + decisions_taken => [ + [ $self->resolution_space, $old_ss ], + @{$old_ss->decisions_taken} + ], ); my $new_ss = $self->_apply_to_ss($ss); return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss; diff --git a/lib/DX/Types.pm b/lib/DX/Types.pm index 3434bb2..b34565b 100644 --- a/lib/DX/Types.pm +++ b/lib/DX/Types.pm @@ -36,7 +36,7 @@ class_type DictValue => { class => 'DX::Value::Dict' }; declare PropositionList => as ArrayRef[Proposition]; -declare AdjustmentList => as ArrayRef[Tuple[Step, SearchState]]; +declare DecisionList => as ArrayRef[Tuple[ResolutionSpace, SearchState]]; declare DependencyType => where { foreach my $cand (EXISTENCE_OF, TYPE_OF, INDICES_OF, CONTENTS_OF) {