clean up resolveproposition code
Matt S Trout [Mon, 16 Apr 2018 01:51:22 +0000 (01:51 +0000)]
lib/DX/Step/ResolveProposition.pm

index 15ecf86..c714458 100644 (file)
@@ -12,14 +12,6 @@ with 'DX::Role::Step';
 
 has resolution_space => (is => 'ro', isa => ResolutionSpace);
 
-sub resolves { shift->resolution_space->proposition }
-
-sub current_resolution { shift->resolution_space->next_resolution }
-
-sub actions { shift->current_resolution->actions }
-
-sub depends_on { shift->current_resolution->veracity_depends_on }
-
 sub but_first {
   my ($self, @actions) = @_;
   $self->but(actions => [ @actions, @{$self->actions} ]);
@@ -32,17 +24,21 @@ sub but_with_dependencies_on {
 
 sub apply_to {
   my ($self, $old_ss) = @_;
+  my $rspace = $self->resolution_space;
+  my $prop = $rspace->proposition;
+  my $res = $rspace->next_resolution;
+  my $vdeps = $res->veracity_depends_on;
   trace resolve => [ statement => [
     [ symbol => 'resolve' ],
     [ block => [
       [ statement => [
         [ symbol => 'proposition' ],
-        @{$self->resolves->for_deparse->[1]},
+        @{$prop->for_deparse->[1]},
       ] ],
-      (@{$self->actions}
+      (@{$res->actions}
         ? [ statement => [
             [ symbol => 'actions' ],
-            [ block => $self->actions ],
+            [ block => $res->actions ],
           ] ]
         : ()),
       [ statement => [
@@ -51,12 +47,11 @@ sub apply_to {
           map [ statement => [
             [ symbol => (split '::', ${$_->[0]})[-1] ],
             [ value_path => [ @{$_}[1..$#$_] ] ]
-          ] ], @{$self->depends_on}
+          ] ], @{$vdeps}
         ] ],
       ] ],
     ] ]
   ] ];
-  my $rspace = $self->resolution_space;
   my $ss = $old_ss->but(
     next_step => DX::Step::CompleteResolution->new(
       original_search_state => $old_ss,
@@ -65,7 +60,7 @@ sub apply_to {
   );
   my $old_hyp = $old_ss->current_hypothesis;
   (my $hyp, my @recheck) = $old_hyp->with_resolution(
-    $self->resolves, $self->depends_on, $self->actions
+    $prop, $vdeps, $res->actions
   );
   return $ss->but(next_step => DX::Step::Backtrack->new) unless $hyp;
   return $ss->but(current_hypothesis => $hyp) unless @recheck;