$class->new(deps => {}, revdeps => {});
}
-sub with_entry_for {
+sub with_dependencies_for {
my ($self, $for_id, $deps_for) = @_;
+ my $old_revdeps = $self->revdeps;
my $new_revdeps = {
- %{$self->revdeps},
- $for_id => $deps_for,
+ %{$old_revdeps},
+ $for_id => [ @{$old_revdeps->{$for_id}||[]}, @$deps_for ],
};
my $new_deps = $self->_merge_deps_for(
$self->deps, $for_id, @$deps_for
return $root->[0];
}
-sub _dependents_of {
+sub dependents_of {
my ($self, $event) = @_;
my ($type, @path) = @$event;
my $root = [ $self->deps ];
sub but_expire_dependents_of {
my ($self, @events) = @_;
my @expired = keys %{{
- map +($_ => 1), map $self->_dependents_of($_), @events
+ map +($_ => 1), map $self->dependents_of($_), @events
}};
# Didn't expire anything? Don't clone self
return $self unless @expired;
sub next_step {
my ($self) = @_;
- return DX::Step::Backtrack->new unless @{$self->members};
- return DX::Step::ResolveProposition->new(resolution_space => $self);
+ my $step_type = (@{$self->members} ? 'ResolveProposition' : 'Backtrack');
+ return "DX::Step::${step_type}"->new(resolution_space => $self);
}
1;
my ($self, $prop, $deps) = @_;
my $id = my @already = @{$self->propositions};
my $new_depmap = $self->dependency_map
- ->with_entry_for($id, $deps);
+ ->with_dependencies_for($id, $deps);
ref($self)->new(
dependency_map => $new_depmap,
propositions => [ @already, $prop ],
# 0 is valid, undef means the grep failed
die "Unable to find $prop in proplist" unless defined $id;
my $new_depmap = $self->dependency_map
- ->with_entry_for($id, $deps);
+ ->with_dependencies_for($id, $deps);
ref($self)->new(
dependency_map => $new_depmap,
propositions => \@props,