|
243 | 243 | % Run the primary source-printing predicate within `run_pl_source/1`. |
244 | 244 | run_pl_source(print_pl_source0(P)). |
245 | 245 |
|
| 246 | +%pnotrace(G):- !, call(G). |
246 | 247 | pnotrace(G):- notrace(G). |
247 | 248 | %pnotrace(G):- quietly(G). |
248 | 249 |
|
|
596 | 597 | mvar_str(S,N) :- % For an unbound variable without a name, format it as `$<variable>`. |
597 | 598 | attvar(S), notrace,ignore(nortrace), |
598 | 599 | with_output_to(string(SS),ignore((get_attrs(S,Attrs),display(Attrs)))), |
599 | | - trace, |
| 600 | + %trace, |
600 | 601 | sformat(N,'a-~w-~w', [SS,S]). % bou |
601 | 602 | mvar_str(S,N) :- % For an unbound variable without a name, format it as `$<variable>`. |
602 | 603 | var(S), !, sformat(N,'~p', [S]). |
|
764 | 765 | % display(v=V), |
765 | 766 | no_type_unification(( |
766 | 767 | % Guess variables in V and pretty-print using `pp_sex/1`. |
| 768 | + |
767 | 769 | undo_bindings(pnotrace(( |
768 | | - gather_src_and_goal(V,Nat,NatGoals), |
769 | | - once((pp_sex(Nat))), |
770 | | - maybe_write_goals(NatGoals)))))), !. |
| 770 | + term_variables(V,Vars), |
| 771 | + copy_term(V+Vars,CV+CVars,_), |
| 772 | + maplist(transfer_varname,Vars,CVars), |
| 773 | + ((CVars=@=Vars) |
| 774 | + -> pp_sex(V); |
| 775 | + (gather_src_and_goal(V,Nat,NatGoals), |
| 776 | + unify_with_occurs_check(CV,Nat), |
| 777 | + write_src_ng(CV,NatGoals)))))))),!. |
| 778 | + |
| 779 | +write_src_ng(Nat,NatGoals):- pp_sex(Nat), |
| 780 | + if_t(NatGoals\==[],if_t(nb_current('$write_goals',true),maybe_write_goals(NatGoals))). |
771 | 781 |
|
772 | 782 | bou:attr_portray_hook(Val,_V):- copy_term(Val,_,Info),!,format(' bou ~w ',[Info]),!. %writeq(break_on_unify(V,Val)),write(' '). |
773 | 783 | bou:attr_unify_hook(_,_):- bt,!,trace,break. |
|
848 | 858 | with_written_goals(Call):- |
849 | 859 | locally(b_setval('$write_goals',true),Call). |
850 | 860 |
|
851 | | -maybe_write_goals(_Goals):- \+ nb_current('$write_goals',true), !. |
852 | | -maybe_write_goals(Goals):- |
853 | | - exclude(is_f_nv,Goals,LGoals), |
854 | | - if_t(LGoals\==[],format(' {<~q>} ', [LGoals])). |
855 | | - %if_t(LGoals\==[],with_output_to(user_error,ansi_format([fg(yellow)], ' {~q} ', [LGoals]))). |
| 861 | +maybe_write_goals(Goals):- Goals==[],!. |
| 862 | +maybe_write_goals(_):- \+ nb_current('$write_goals',true), !. |
| 863 | +maybe_write_goals(Goals):- once(exclude(is_f_nv,Goals,LGoals)),if_t(LGoals\==[],format(' {<~q>} ', [LGoals])). |
| 864 | + |
856 | 865 | is_f_nv(P):- compound(P), functor(P,F,A,_), !, is_f_nv(F,A). |
857 | 866 | is_f_nv(break_on_unify,2). is_f_nv(name_variable,2). |
858 | 867 |
|
|
0 commit comments