format aperture in backtrack trace
[scpubgit/DX.git] / lib / DX / Proposition.pm
1 package DX::Proposition;
2
3 use DX::Step::ConsiderProposition;
4
5 use DX::Class;
6
7 has predicate => (is => 'ro', isa => Str, required => 1);
8
9 has args => (is => 'ro', isa => ArrayRef[Str|Value], required => 1);
10
11 has introduced_names => (is => 'ro', isa => HashRef[One], required => 1);
12
13 has required_names => (is => 'ro', isa => HashRef[One], required => 1);
14
15 sub for_deparse {
16   my ($self) = @_;
17   [ statement => [
18     [ symbol => $self->predicate ],
19     map {
20       ref($_)
21         ? $_
22         : [ symbol => $self->introduced_names->{$_} ? "?$_" : $_ ]
23     } @{$self->args}
24   ] ];
25 }
26
27 sub resolve_for {
28   my ($self, $scope) = @_;
29   my $predicate = $scope->lookup_predicate($self->predicate);
30   my @args = map { ref($_) ? $_ : $scope->lookup($_) } @{$self->args};
31   #if (my $step = $scope->known_facts->resolution_step_for($predicate, @args)) {
32   #  return $step;
33   #}
34   return $predicate->resolution_step_for($self, @args);
35 }
36
37 sub consider_step {
38   my ($self) = @_;
39   DX::Step::ConsiderProposition->new(proposition => $self);
40 }
41
42 1;