Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Nov 29, 2024
1 parent 42d0c9f commit ed9d268
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,29 @@ int retry_choice(query *q)
return 0;
}

static void trim_trail(query *q)
{
if (q->undo_hi_tp)
return;

pl_idx tp;

if (q->cp) {
const choice *ch = GET_CURR_CHOICE();
tp = ch->st.tp;
} else
tp = 0;

while (q->st.tp > tp) {
const trail *tr = q->trails + q->st.tp - 1;

if (tr->var_ctx != q->st.curr_frame)
break;

q->st.tp--;
}
}

static frame *push_frame(query *q, const clause *cl)
{
const frame *curr_f = GET_CURR_FRAME();
Expand Down Expand Up @@ -581,6 +604,7 @@ static void reuse_frame(query *q, const clause *cl)
to->c = from->c;
}

trim_trail(q);
q->st.hp = f->hp;
q->st.heap_nbr = f->heap_nbr;
q->st.sp = f->base + cl->nbr_vars;
Expand All @@ -589,29 +613,6 @@ static void reuse_frame(query *q, const clause *cl)
trim_heap(q);
}

static void trim_trail(query *q)
{
if (q->undo_hi_tp)
return;

pl_idx tp;

if (q->cp) {
const choice *ch = GET_CURR_CHOICE();
tp = ch->st.tp;
} else
tp = 0;

while (q->st.tp > tp) {
const trail *tr = q->trails + q->st.tp - 1;

if (tr->var_ctx != q->st.curr_frame)
break;

q->st.tp--;
}
}

static bool commit_any_choices(const query *q, const frame *f)
{
if (q->cp == 1) // Skip in-progress choice
Expand Down

0 comments on commit ed9d268

Please sign in to comment.