From 79212bf652a66bdb03f3eb32ad56a3021899252b Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Tue, 3 Oct 2023 08:30:03 +1000 Subject: [PATCH] WIP, re issue #354 --- src/attributed.c | 8 ++++++-- src/attributed.h | 2 +- src/query.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/attributed.c b/src/attributed.c index c26512633..877dab44c 100644 --- a/src/attributed.c +++ b/src/attributed.c @@ -210,7 +210,7 @@ bool fn_sys_redo_trail_1(query * q) return true; } -bool do_post_unification_hook(query *q) +bool do_post_unification_hook(query *q, bool is_builtin) { q->run_hook = false; q->undo_lo_tp = q->before_hook_tp; @@ -249,7 +249,11 @@ bool do_post_unification_hook(query *q) if (!tmp[1].match) return throw_error(q, tmp+1, q->st.curr_frame, "existence_error", "procedure"); - make_call_redo(q, tmp+2); + if (is_builtin) + make_call(q, tmp+2); + else + make_call_redo(q, tmp+2); + q->st.curr_cell = tmp; return true; } diff --git a/src/attributed.h b/src/attributed.h index 3a063d28b..499b5d7ec 100644 --- a/src/attributed.h +++ b/src/attributed.h @@ -6,7 +6,7 @@ bool fn_sys_get_attributes_2(query *q); bool fn_sys_unattributed_var_1(query *q); bool fn_sys_attributed_var_1(query *q); -bool do_post_unification_hook(query *q); +bool do_post_unification_hook(query *q, bool is_builtin); bool fn_sys_undo_trail_2(query *q); bool fn_sys_redo_trail_1(query *q); diff --git a/src/query.c b/src/query.c index 321f0aa35..075dfc2c9 100644 --- a/src/query.c +++ b/src/query.c @@ -1581,7 +1581,7 @@ bool start(query *q) } if (q->run_hook) - do_post_unification_hook(q); + do_post_unification_hook(q, true); Trace(q, save_cell, save_ctx, EXIT); proceed(q); @@ -1593,7 +1593,7 @@ bool start(query *q) } if (q->run_hook) - do_post_unification_hook(q); + do_post_unification_hook(q, false); } else { if (consultall(q, q->st.curr_cell, q->st.curr_frame) != true) { q->retry = QUERY_RETRY;