package DX::Op::Prop;
+use DX::VarRef;
use Moo;
with 'DX::Role::Op';
if ($value->can("has_${name}") and not $value->${\"has_${name}"}) {
return $state->backtrack;
}
- return $state->bind_value($args{value}->id, $value->$name)
+ my $var_ref = DX::VarRef->new(var_id => $args{of}->id, derive => $name);
+ return $state->bind_value($args{value}->id, $var_ref)
->add_dependencies($args{value}->id => $args{of}->id)
->then($self->next);
}
--- /dev/null
+package DX::VarRef;
+
+use Moo;
+
+with 'DX::Role::Ref';
+
+has var_id => (is => 'ro', required => 1);
+
+has derive => (is => 'ro', default => sub { $_[0] });
+
+sub resolve {
+ my ($self, $state) = @_;
+ $state->resolve_value($state->by_id->{$self->var_id})->${\$self->derive};
+}
+
+1;