with 'DX::Role::Predicate';
sub _possible_resolution_list {
- my ($self, $coll, $key, $value) = @_;
- die "First argument to member_at must be a structured value"
- unless $coll->does('DX::Role::StructuredValue');
- my $basic_deps = sub {
- (depends_on => [
- [ EXISTENCE_OF ,=> $coll, ($_[1]||$_[0])->string_value ],
- [ CONTENTS_OF ,=> $_[0] ],
- [ CONTENTS_OF ,=> $coll, ($_[1]||$_[0])->string_value ],
- [ CONTENTS_OF ,=> $value ],
- ])
- };
- if ($value->is_set) {
- # Already set values are only supported for recheck
- trace member_at => "+D +K +V";
- return () unless $key->is_set and my $cur_val = $coll->get_member_at($key);
- return () unless $cur_val->equals($value);
- return step(
- actions => [],
- $basic_deps->($key),
- );
- }
- die "Bizarre: member_at called with non-fresh unset value"
- unless $value->action_builder->isa('DX::ActionBuilder::UnsetValue');
- if ($key->is_set) {
- trace member_at => "+D +K -V";
- if (my $cur_val = $coll->get_member_at($key)) {
- my $set = $value->action_for_set_value($cur_val);
- return step(
- actions => [ $set ],
- $basic_deps->($key),
- );
- }
- if (my $p = $coll->value_path) {
- my @path = (@$p, $key->string_value);
- my $ab = DX::ActionBuilder::ProxySetToAdd->new(
- target_path => \@path,
- proxy_to => $coll->action_builder,
- );
- my $set = $value->action_for_set_value(
- $value->but(
- action_builder => $ab
- )
- );
- return step(
- actions => [ $set ],
- $basic_deps->($key),
- );
- }
- return ();
- }
- die "Bizarre: member_at called with non-fresh unset key"
- unless $key->action_builder->isa('DX::ActionBuilder::UnsetValue');
- trace member_at => "+D -K -V";
+ my ($self, @args) = @_;
+ my $rspace = $self->_resolution_space_for(@args);
+ return () unless my @members = @{$rspace->members};
return map {
- my $set_key = $key->action_for_set_value(my $kstr = string($_));
- my $set_value = $value->action_for_set_value($coll->get_member_at($kstr));
- step(
- actions => [ $set_key, $set_value ],
- $basic_deps->($key, $kstr),
- );
- } $coll->index_list;
-}
-
-sub selection_depends_on {
- my ($self, $coll, $key, $value) = @_;
- die "NEEDS REDOING";
- [ [ $coll => ($key->can_set_value ? INDICES_OF : (EXISTENCE_OF ,=> $key)) ],
- $key,
- $value,
- ]
+ $_->isa('DX::Resolution')
+ ? step(
+ actions => $_->actions,
+ depends_on => $_->veracity_depends_on,
+ )
+ : do {
+ my ($db, @ap) = (
+ $_->veracity_depends_on_builder, @{$_->action_prototypes}
+ );
+ map {
+ my @cand = @{$_};
+ step(
+ actions => [
+ map {
+ my ($inv, $type, @args) = @{$ap[$_]};
+ $inv->${\"action_for_${type}"}(@args, @{$cand[$_]});
+ } 0..$#ap
+ ],
+ depends_on => $db->(@cand),
+ )
+ } @{$_->implementation_candidates};
+ }
+ } @members;
}
# member_at Dict Key Value
[ $value => 'set_value' ],
],
veracity_depends_on_builder => sub {
- my ($this_key, $this_val) = @_;
+ my ($this_key, $this_val) = map @$_, @_;
return [
[ CONTENTS_OF ,=> $dict, $this_key->string_value ],
[ CONTENTS_OF ,=> $key ],