--- /dev/null
+?
+is_dict ?X
+eq ?Y X
+qact
+eq Y {{ foo 1 }}
+qact
+.
--- /dev/null
+package DX::Action::BindValue;
+
+use DX::Update::SetValue;
+use DX::ActionBuilder::BoundValue;
+use DX::Class;
+
+with 'DX::Role::SimpleAction';
+
+has new_value => (is => 'ro', required => 1);
+
+sub _build__updates {
+ my ($self) = @_;
+ DX::Update::SetValue->new(
+ target_path => $self->target_path,
+ new_value => $self->new_value,
+ );
+}
+
+1;
+
--- /dev/null
+package DX::Action::SetBoundValue;
+
+use DX::Update::SetValue;
+use DX::Class;
+
+with 'DX::Role::Action';
+
+has target_path => (is => 'ro', required => 1);
+
+has rebind_path => (is => 'ro', required => 1);
+
+has new_value => (is => 'ro', required => 1);
+
+has inner_action => (is => 'ro', required => 1);
+
+sub dry_run {
+ my ($self, $hyp) = @_;
+ my ($outer_hyp, @inner_events) = $self->inner_action->dry_run($hyp);
+ my ($scope, @events) = $outer_hyp->scope->apply_updates(
+ DX::Update::SetValue->new(
+ target_path => $self->target_path,
+ new_value => $self->new_value,
+ )
+ );
+ my $new_bound = do {
+ my $targ = $scope;
+ $targ = $targ->get_member_at($_) for @{$self->rebind_path};
+ $targ;
+ };
+ my @actions = @{$outer_hyp->actions};
+ foreach my $idx (0.. $#actions) {
+ my $act = $actions[$idx];
+ if (
+ $act->isa('DX::Action::BindValue')
+ and join("\0", @{$act->target_path})
+ eq join("\0", @{$self->rebind_path})
+ ) {
+ my $bind = splice @actions, $idx, 1;
+ push @actions, $bind->but(new_value => $new_bound);
+ last;
+ }
+ }
+ return (
+ $outer_hyp->but(scope => $scope, actions => \@actions),
+ @inner_events, @events
+ );
+}
+
+sub run { die }
+
+1;
--- /dev/null
+package DX::ActionBuilder::BoundValue;
+
+use DX::Action::SetBoundValue;
+#use DX::Action::AddBoundValue;
+use DX::Class;
+
+with 'DX::Role::ActionBuilder';
+
+has target_path => (is => 'ro', required => 1);
+
+has rebind_path => (is => 'ro', required => 1);
+
+has bound_to_path => (is => 'ro', required => 1);
+
+has inner_action_builder => (is => 'ro', required => 1);
+
+sub action_for_set_value {
+ my ($self, $value) = @_;
+ my $inner_action = $self->inner_action_builder->action_for_set_value($value);
+ return undef unless $inner_action;
+ DX::Action::SetBoundValue->new(
+ target_path => $self->target_path,
+ rebind_path => $self->rebind_path,
+ new_value => $value->but_set_action_builder($self)
+ ->but_set_identity_path($self->bound_to_path),
+ inner_action => $inner_action,
+ )
+}
+
+1;
use DX::Action::SetValue;
use DX::ActionBuilder::Normal;
+use DX::Action::BindValue;
+use DX::ActionBuilder::BoundValue;
use DX::Class;
with 'DX::Role::ActionBuilder';
sub action_for_set_value {
my ($self, $value) = @_;
- if (0) { # value_path / identity_path test
- # bind value
+ if (my $p = $value->identity_path) {
+ my $ab = DX::ActionBuilder::BoundValue->new(
+ target_path => $self->target_path,
+ rebind_path => $self->target_path,
+ bound_to_path => $p,
+ inner_action_builder => $value->action_builder,
+ );
+ return DX::Action::BindValue->new(
+ target_path => $self->target_path,
+ new_value => $value->but_set_action_builder($ab),
+ )
}
my $ab = DX::ActionBuilder::Normal->new(
target_path => $self->target_path,
$self->_fmt_action_generic(AddValue => $action, $meta);
}
+sub _fmt_action_bindvalue {
+ my ($self, $action, $meta) = @_;
+ $self->_fmt_action_generic(BindValue => $action, $meta);
+}
+
sub _fmt_action_generic {
my ($self, $name, $action, $meta) = @_;
my $path = join '.', map $self->_fmt($_, $meta), @{$action->target_path};
push our @Result, [ output => $rps ];
return;
});
+ $tcl->CreateCommand(qact => sub {
+ my $act = $self->shell_state->current_query_state->search_state
+ ->current_hypothesis->actions;
+ push our @Result, map [ output => $_ ], @$act;
+ return;
+ });
foreach my $pred (
keys %{$self->shell_state->template_query_state->predicates}
) {