From: Matt S Trout Date: Sun, 3 Apr 2016 17:39:09 +0000 (+0000) Subject: switch to passing prop to resolve in, fix bug in with_one_step, update output X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5787d20d93bd3208d2ae41ead77c983ae9318d69;p=scpubgit%2FDX.git switch to passing prop to resolve in, fix bug in with_one_step, update output --- diff --git a/fragment.output/bind b/fragment.output/bind index 7e050d4..5df256a 100644 --- a/fragment.output/bind +++ b/fragment.output/bind @@ -2,31 +2,38 @@ $ ? ? dict ?X SetValue 0.X {{ }} ? eq ?Y X +BindValue 0.Y 0.X ? qact SetValue 0.X {{ }} -? eq Y {{ foo 1 }} BindValue 0.Y 0.X +? eq Y {{ foo 1 }} +SetBoundValue 0.Y {{ foo 1 }} +SetValue 0.X {{ foo 1 }} ? qact SetValue 0.X {{ }} +SetValue 0.X {{ foo 1 }} BindValue 0.Y 0.X ? . -{{ X {{ }} Y {{ }} }} +{{ X {{ foo 1 }} Y {{ foo 1 }} }} $ ? ? dict ?X {{ foo {{ bar 1 }} }} SetValue 0.X {{ foo {{ bar 1 }} }} ? member_at X 'foo' ?Y -? member_at Y 'bar' ?Z BindValue 0.Y 0.X.foo -? eq Z 2 +? member_at Y 'bar' ?Z BindValue 0.Z 0.Y.bar -? member_at Y 'baz' 4 +? eq Z 2 SetBoundValue 0.Z 2 SetBoundValue 0.Y.bar 2 SetValue 0.X.foo.bar 2 +? member_at Y 'baz' 4 +AddBoundValue 0.Y.baz 4 +AddValue 0.X.foo.baz 4 ? qact SetValue 0.X {{ foo {{ bar 1 }} }} SetValue 0.X.foo.bar 2 -BindValue 0.Y 0.X.foo BindValue 0.Z 0.Y.bar +AddValue 0.X.foo.baz 4 +BindValue 0.Y 0.X.foo ? . -{{ X {{ foo {{ bar 2 }} }} Y {{ bar 2 }} Z 2 }} +{{ X {{ foo {{ bar 2 baz 4 }} }} Y {{ bar 2 baz 4 }} Z 2 }} diff --git a/fragment.output/const b/fragment.output/const index 5e4fc43..0aebc72 100644 --- a/fragment.output/const +++ b/fragment.output/const @@ -7,6 +7,5 @@ BindValue 0.OS systems.agaton ? eq OS 'debian' ? ... {{ Name 'agaton' OS 'debian' }} -{{ Name 'hatebox' OS 'rhel' }} {{ Name 'sherlock' OS 'debian' }} No next solution diff --git a/fragment.output/member_at b/fragment.output/member_at index 3681421..73bae31 100644 --- a/fragment.output/member_at +++ b/fragment.output/member_at @@ -2,8 +2,12 @@ $ ? ? eq ?X {{ a 1 b 2 c 3 }} SetValue 0.X {{ a 1 b 2 c 3 }} ? member_at X ?Y ?Z +SetValue 0.Y 'a' +BindValue 0.Z 0.X.a ? ... -{{ X {{ a 1 b 2 c 3 }} Y unset Z unset }} +{{ X {{ a 1 b 2 c 3 }} Y 'a' Z 1 }} +{{ X {{ a 1 b 2 c 3 }} Y 'b' Z 2 }} +{{ X {{ a 1 b 2 c 3 }} Y 'c' Z 3 }} No next solution $ qlist eq ?X {{ a 1 b 2 c 3 }} @@ -12,13 +16,11 @@ $ ? ? eq ?X {{ a 1 b 2 c 3 }} SetValue 0.X {{ a 1 b 2 c 3 }} ? member_at X ?Y ?Z -? eq Z 2 SetValue 0.Y 'a' BindValue 0.Z 0.X.a +? eq Z 2 ? ... -{{ X {{ a 1 b 2 c 3 }} Y 'a' Z 1 }} {{ X {{ a 1 b 2 c 3 }} Y 'b' Z 2 }} -{{ X {{ a 1 b 2 c 3 }} Y 'c' Z 3 }} No next solution $ qlist eq ?X {{ a 1 b 2 c 3 }} diff --git a/lib/DX/Hypothesis.pm b/lib/DX/Hypothesis.pm index 95c05f3..ff04996 100644 --- a/lib/DX/Hypothesis.pm +++ b/lib/DX/Hypothesis.pm @@ -91,13 +91,13 @@ sub but_recheck_for { return $self->but(resolved_propositions => $rps); } -sub resolve_head_dependent_on { - my ($self, $depends) = @_; +sub with_resolution { + my ($self, $prop, $depends) = @_; my ($first, @rest) = @{$self->outstanding_propositions}; $self->but( resolved_propositions => $self->resolved_propositions ->with_resolution_for( - $first, + $prop, $depends, ), outstanding_propositions => \@rest, diff --git a/lib/DX/SearchState.pm b/lib/DX/SearchState.pm index 9c831df..8ed1d87 100644 --- a/lib/DX/SearchState.pm +++ b/lib/DX/SearchState.pm @@ -13,9 +13,10 @@ has propositions => (is => 'ro', isa => PropositionSequence, required => 1); has alternatives => (is => 'ro', isa => AlternativeList, required => 1); sub next_proposition { - my ($self) = @_; + my ($self, $hyp) = @_; + $hyp ||= $self->current_hypothesis; $self->propositions->members->[ - $self->current_hypothesis->resolved_propositions->resolved_count + $hyp->resolved_propositions->resolved_count ]; } @@ -47,7 +48,7 @@ sub with_one_step { @alt ], next_step => DX::Step::InvokeNextPredicate->new( - proposition => $self->next_proposition, + proposition => $self->next_proposition($new_hyp), ), ); } diff --git a/lib/DX/Step/Normal.pm b/lib/DX/Step/Normal.pm index 9488e74..d5bb1e3 100644 --- a/lib/DX/Step/Normal.pm +++ b/lib/DX/Step/Normal.pm @@ -37,7 +37,7 @@ sub apply_to { sub _apply_to_hyp { my ($self, $old_hyp) = @_; return undef unless my $hyp = $old_hyp->with_actions(@{$self->actions}); - return $hyp->resolve_head_dependent_on($self->depends_on); + return $hyp->with_resolution($self->resolves, $self->depends_on); } 1;