Skip to content

Commit

Permalink
Work on residuals printing, re issue #443
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Jun 4, 2024
1 parent f9887e6 commit eaeddac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions library/builtins.pl
Original file line number Diff line number Diff line change
Expand Up @@ -712,25 +712,26 @@

% Debugging...

print_goals_([]).
print_goals_([Goal|Goals]) :-
print_goals_(_, []).
print_goals_(Any, [Goal|Goals]) :-
(Any -> write(', ') ; true),
write(Goal),
(Goals == [] -> true ; write(', ')),
print_goals_(Goals).
print_goals_(false, Goals).

dump_attvars_([], []).
dump_attvars_([Var|Vars], [Gs|Rest]) :-
copy_term(Var, Var2, Gs),
Var = Var2,
dump_attvars_(Vars, Rest).

dump_attvars :-
dump_attvars(Any) :-
'$list_attributed'(Vs0),
sort(Vs0, Vs),
dump_attvars_(Vs, Gs0),
flatten(Gs0, Gs1),
sort(Gs1, Gs),
print_goals_(Gs).
print_goals_(Any, Gs).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
Expand Down
11 changes: 6 additions & 5 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ void dump_vars(query *q, bool partial)
bool any_atts = any_attributed(q);

if (any && any_atts)
fprintf(stdout, "%s", ", ");
fprintf(stdout, "%s", "");
else if (any_atts && !q->is_redo)
fprintf(stdout, "%s", " ");
else if (any_atts)
Expand All @@ -477,10 +477,11 @@ void dump_vars(query *q, bool partial)
q->variable_names = vlist;
q->variable_names_ctx = q->st.curr_frame;
q->tab_idx = 0;
cell p1;
make_atom(&p1, new_atom(q->pl, "dump_attvars"));
cell *tmp = prepare_call(q, NOPREFIX_LEN, &p1, q->st.curr_frame, 1);
pl_idx nbr_cells = p1.nbr_cells;
cell p1[2];
make_struct(p1+0, new_atom(q->pl, "dump_attvars"), NULL, 1, 1);
make_atom(p1+1, any ? g_true_s : g_false_s);
cell *tmp = prepare_call(q, NOPREFIX_LEN, p1, q->st.curr_frame, 1);
pl_idx nbr_cells = p1->nbr_cells;
make_end(tmp+nbr_cells);
q->st.curr_instr = tmp;
q->in_attvar_print = true;
Expand Down

0 comments on commit eaeddac

Please sign in to comment.