#if (my $step = $scope->known_facts->resolution_step_for($predicate, @args)) {
# return $step;
#}
- return $predicate->resolution_step_for(@args);
+ return $predicate->resolution_step_for($self, @args);
}
1;
use DX::Role;
sub resolution_step_for {
- my ($self, @args) = @_;
+ my ($self, $prop, @args) = @_;
my ($last, @rest) = reverse $self->_possible_resolution_list(@args);
return undef unless $last;
- my $targ = $last;
- $targ = $_->but_with_alternative_step($targ) for @rest;
+ my $targ = $last->but(resolves => $prop);
+ $targ = $_->but(
+ alternative_step => $targ,
+ resolves => $prop
+ ) for @rest;
return $targ;
}
has alternatives => (is => 'ro', isa => AlternativeList, required => 1);
+sub next_proposition { $_[0]->current_hypothesis->head_proposition }
+
sub new_for {
my ($class, $hyp) = @_;
$class->new(
current_hypothesis => $hyp,
alternatives => [],
- next_step => DX::Step::InvokeNextPredicate->new,
+ next_step => DX::Step::InvokeNextPredicate->new(
+ proposition => $hyp->head_proposition,
+ ),
);
}
: ()),
@alt
],
- next_step => DX::Step::InvokeNextPredicate->new,
+ next_step => DX::Step::InvokeNextPredicate->new(
+ proposition => $self->next_proposition,
+ ),
);
}
if ($alt_step) {
with 'DX::Role::Step';
+has proposition => (is => 'ro', required => 1);
+
sub apply_to {
my ($self, $hyp) = @_;
- return (undef, $hyp->head_proposition->resolve_for($hyp->scope));
+ return (undef, $self->proposition->resolve_for($hyp->scope));
}
1;
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) = @_;
trace 'step.apply.old_hyp '.$self => $old_hyp;