4 use List::UtilsBy qw(sort_by);
8 my @dep_types = qw(CONTENTS_OF INDICES_OF TYPE_OF EXISTENCE_OF),
9 my @ev_types = qw(VALUE_SET VALUE_EXISTS),
14 (my @builders = qw(rspace rstrat res string number dict proposition)),
15 'deparse', '*trace', 'expand_deps', 'format_deps', 'compact_deps',
20 dep_types => \@dep_types,
21 event_types => \@ev_types,
22 builders => \@builders,
27 # use constant INDICES_OF => \*INDICES_OF;
30 map {; no strict 'refs'; $_ => \*$_ } @const
33 # $CONTENTS_OF = 1, ... # stronger dependency has lower number
35 do { no strict 'refs'; ${$dep_types[$_-1]} = $_ } for 1..@dep_types;
37 # VALUE_EXISTS needs to trigger indices checks on its parent
39 our $VALUE_EXISTS = 1;
41 # VALUE_EXISTS triggers all types, VALUE_SET all but EXISTENCE_OF
43 our @VALUE_EXISTS = (EXISTENCE_OF(), TYPE_OF(), INDICES_OF(), CONTENTS_OF());
44 our @VALUE_SET = (TYPE_OF(), INDICES_OF(), CONTENTS_OF());
49 my ($type, @path) = @{$_[0]};
51 ref() ? @{$_->value_path or return ()} : $_
53 return [ $type, @expanded ];
57 [ map _expand_dep($_), @{$_[0]} ]
63 [ symbol => (split '::', ${$_->[0]})[-1] ],
64 [ value_path => [ @{$_}[1..$#$_] ] ]
71 my @sorted = sort_by { join "\0", @{$_->[0]} }
72 map { [ [ join("\0", @{$_}[1..$#$_], ''), $${$_->[0]} ], $_ ] } @$deps;
74 while (my $s = shift @sorted) {
75 my ($path, $type) = @{$s->[0]};
76 shift @sorted while @sorted and $sorted[0][0][0] eq $path;
77 if ($type == 1) { # CONTENTS_OF dep, prune children
78 my $len = length($path);
79 shift @sorted while @sorted and substr($sorted[0][0][0], 0, $len) eq $path;
81 if ($type == 2) { # INDICES_OF dep, drop immediately below EXISTENCE_OF
82 my $len = length($path);
83 my $parts = @{$s->[1]} + 1;
85 while (@sorted and substr($sorted[0][0][0], 0, $len) eq $path) {
86 my $check = shift @sorted;
87 unless ($check->[0][1] == 4 and @{$check->[1]} == $parts) {
91 unshift @sorted, @keep;
93 push @compacted, $s->[1];
99 require DX::ResolutionSpace;
100 DX::ResolutionSpace->new(@_);
104 require DX::ResolutionStrategy;
105 DX::ResolutionStrategy->new(@_);
109 require DX::Resolution;
110 DX::Resolution->new(@_);
114 require DX::Value::String;
115 DX::Value::String->new(string_value => $_[0])
119 require DX::Value::Number;
120 DX::Value::Number->new(number_value => $_[0]);
124 require DX::Value::Dict;
125 DX::Value::Dict->new(
131 my ($pred, @args) = @_;
132 require DX::Proposition;
133 DX::Proposition->new(
144 require DX::TraceFormatter;
145 DX::TraceFormatter->new;