has depends_on => (is => 'ro', isa => DependencyGroupList, required => 1);
+has resolves => (is => 'ro', isa => Proposition);
+
has alternative_step => (is => 'ro', isa => Step);
sub but_first {
$self->but(depends_on => [ @{$self->depends_on}, @deps ]);
}
-sub but_with_alternative_step {
- my ($self, $step) = @_;
- bless { %$self, alternative_step => $step }, ref($self);
-}
-
sub apply_to {
- my ($self, $old_hyp) = @_;
- return ($self->_apply_to_hyp($old_hyp), $self->alternative_step);
+ 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;
+ my $ns = DX::Step::InvokeNextPredicate->new(
+ proposition => $ss->next_proposition($new_hyp)
+ );
+ return (
+ $ss->but(
+ current_hypothesis => $new_hyp,
+ next_step => $ns,
+ ),
+ $self->alternative_step
+ );
}
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;