show resolve step dependency info
[scpubgit/DX.git] / lib / DX / Deparse.pm
index df624c5..228c1b0 100644 (file)
@@ -81,7 +81,7 @@ sub _fmt_hypothesis {
   my ($self, $hyp, $meta) = @_;
   $self->_fmt_object([
     map [ $_ => $hyp->$_ ],
-      qw(actions outstanding_propositions resolved_propositions scope)
+      qw(actions resolved_propositions scope)
   ], $meta);
 }
 
@@ -110,6 +110,28 @@ sub _fmt_action_addvalue {
   $self->_fmt_action_generic(AddValue => $action, $meta);
 }
 
+sub _fmt_action_bindvalue {
+  my ($self, $action, $meta) = @_;
+  my $path = join '.', map $self->_fmt($_, $meta), @{$action->target_path};
+  my $bound_path = join '.',
+                     map $self->_fmt($_, $meta),
+                       @{$action->new_value
+                                ->action_builder
+                                ->inner_action_builder
+                                ->target_path};
+  join ' ', BindValue => $path, $bound_path;
+}
+
+sub _fmt_action_addboundvalue {
+  my ($self, $action, $meta) = @_;
+  $self->_fmt_action_generic(AddBoundValue => $action, $meta);
+}
+
+sub _fmt_action_setboundvalue {
+  my ($self, $action, $meta) = @_;
+  $self->_fmt_action_generic(SetBoundValue => $action, $meta);
+}
+
 sub _fmt_action_generic {
   my ($self, $name, $action, $meta) = @_;
   my $path = join '.', map $self->_fmt($_, $meta), @{$action->target_path};
@@ -138,7 +160,9 @@ sub _fmt_proposition {
   my ($self, $prop, $meta) = @_;
   join ' ',
     $prop->predicate,
-    map $self->_fmt($_, $meta), @{$prop->args};
+    map $self->_fmt($_, $meta),
+      map +((!ref($_) and $prop->introduced_names->{$_}) ? "?$_" : $_),
+        @{$prop->args};
 }
 
 sub _fmt_scope {
@@ -157,4 +181,37 @@ sub _fmt_searchstate {
   ], $meta);
 }
 
+sub _fmt_step_considerproposition {
+  my ($self, $step, $meta) = @_;
+  'consider '.$self->_fmt($step->proposition, $meta);
+}
+
+sub _fmt_step_resolveproposition {
+  my ($self, $step, $meta) = @_;
+  'resolve '.$self->_fmt_object([
+    [ actions => $step->actions ],
+    ($step->alternative_step
+      ? [ alternative_step => '...' ]
+      : ()),
+    [ depends_on => [
+      map bless([ @$_ ], 'DX::Dependency'),
+        map @{$_}[1..$#$_],
+          @{$step->depends_on}
+    ] ],
+  ], $meta);
+}
+
+sub _fmt_step_backtrack { 'backtrack' }
+
+sub _fmt_step_markassolution { 'mark as solution' }
+
+sub _fmt_step_enterrecheck {
+  my ($self, $step, $meta) = @_;
+  'recheck '.$self->_fmt($step->proposition_list->[0], $meta);
+}
+
+sub _fmt_step_completerecheck { 'complete recheck' }
+
+sub _fmt_step_failrecheck { 'fail recheck' }
+
 1;