Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Sep 13, 2024
1 parent 1fe0d63 commit f13399e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/bif_maps.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static bool bif_engine_create_4(query *q)
str->first_time = str->is_engine = true;
str->curr_yield = NULL;

str->engine = query_create(q->st.m, true);
str->engine = query_create(q->st.m);
str->engine->curr_engine = n;
str->engine->is_engine = true;
str->engine->trace = q->trace;
Expand Down
2 changes: 1 addition & 1 deletion src/bif_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ static bool bif_thread_create_3(query *q)
cell *goal = deep_clone_to_tmp(q, p1, p1_ctx);
check_heap_error(goal);
t->nbr_vars = rebase_term(q, goal, 0);
t->q = query_create(q->st.m, false);
t->q = query_create(q->st.m);
check_heap_error(t->q);
t->q->thread_ptr = t;
t->q->my_chan = n;
Expand Down
2 changes: 1 addition & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ bool do_use_module_2(module *curr_m, cell *c)
pr2->alias = pr;
} else if (is_structure(lhs) && is_structure(rhs)) {
// assertz(goal_expansion(rhs, module:lhs))
query *q = query_create(curr_m, false);
query *q = query_create(curr_m);
check_error(q);
q->varnames = true;
char *dst1 = print_canonical_to_strbuf(q, rhs, 0, 0);
Expand Down
10 changes: 5 additions & 5 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ static bool goal_run(parser *p, cell *goal)
if (goal->val_off == g_cut_s)
return false;

query *q = query_create(p->m, false);
query *q = query_create(p->m);
execute(q, goal, MAX_ARITY);

if (q->retry != QUERY_OK) {
Expand Down Expand Up @@ -1767,7 +1767,7 @@ void reset(parser *p)

static bool dcg_expansion(parser *p)
{
query *q = query_create(p->m, false);
query *q = query_create(p->m);
check_error(q);

q->trace = false;
Expand Down Expand Up @@ -1849,7 +1849,7 @@ static bool term_expansion(parser *p)
if (h->val_off == g_colon_s)
return false;

query *q = query_create(m, true);
query *q = query_create(m);
check_error(q);
q->trace = false;
cell *c = p->cl->cells;
Expand Down Expand Up @@ -1926,7 +1926,7 @@ static cell *goal_expansion(parser *p, cell *goal)
return goal;
}

query *q = query_create(p->m, true);
query *q = query_create(p->m);
check_error(q);
q->trace = false;
q->varnames = true;
Expand Down Expand Up @@ -4034,7 +4034,7 @@ bool run(parser *p, const char *pSrc, bool dump, query **subq, unsigned int yiel
return true;
}

query *q = query_create(p->m, false);
query *q = query_create(p->m);

if (!q) {
p->srcptr = NULL;
Expand Down
20 changes: 10 additions & 10 deletions src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ static void msleep(int ms)

static const unsigned INITIAL_NBR_QUEUE_CELLS = 1000;
static const unsigned INITIAL_NBR_HEAP_CELLS = 1000;
static const unsigned INITIAL_NBR_FRAMES = 1000;
static const unsigned INITIAL_NBR_SLOTS = 4000;
static const unsigned INITIAL_NBR_TRAILS = 4000;
static const unsigned INITIAL_NBR_CHOICES = 1000;
static const unsigned INITIAL_NBR_SLOTS = 1000;
static const unsigned INITIAL_NBR_TRAILS = 1000;
static const unsigned INITIAL_NBR_CHOICES = 100;
static const unsigned INITIAL_NBR_FRAMES = 100;
static const unsigned INITIAL_NBR_CELLS = 100;

int g_tpl_interrupt = 0;
Expand Down Expand Up @@ -1931,7 +1931,7 @@ void query_destroy(query *q)
free(q);
}

query *query_create(module *m, bool is_sub_query)
query *query_create(module *m)
{
static pl_atomic uint64_t g_query_id = 0;
query *q = calloc(1, sizeof(query));
Expand All @@ -1955,10 +1955,10 @@ query *query_create(module *m, bool is_sub_query)

// Allocate these now...

q->frames_size = is_sub_query ? 100 : INITIAL_NBR_FRAMES;
q->choices_size = is_sub_query ? 100 : INITIAL_NBR_CHOICES;
q->slots_size = is_sub_query ? 1000 : INITIAL_NBR_SLOTS;
q->trails_size = is_sub_query ? 1000 : INITIAL_NBR_TRAILS;
q->frames_size = INITIAL_NBR_FRAMES;
q->choices_size = INITIAL_NBR_CHOICES;
q->slots_size = INITIAL_NBR_SLOTS;
q->trails_size = INITIAL_NBR_TRAILS;

ensure(q->frames = calloc(q->frames_size, sizeof(frame)), NULL);
ensure(q->choices = calloc(q->choices_size, sizeof(choice)), NULL);
Expand All @@ -1979,7 +1979,7 @@ query *query_create(module *m, bool is_sub_query)

query *query_create_subquery(query *q, cell *curr_instr)
{
query *task = query_create(q->st.m, true);
query *task = query_create(q->st.m);
if (!task) return NULL;
task->parent = q;
task->st.fp = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ typedef struct {
const char *functor;
} csv;

query *query_create(module *m, bool sub_query);
query *query_create(module *m);
query *query_create_subquery(query *q, cell *curr_instr);
query *query_create_task(query *q, cell *curr_instr);
void query_destroy(query *q);
Expand Down

0 comments on commit f13399e

Please sign in to comment.