diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 31 |
1 files changed, 4 insertions, 27 deletions
@@ -11,33 +11,10 @@ Builtin findbuiltin(Term *); void addchoicepoints(Clause *, Term *, Goal *, Module *); int -evalquery(Term *query, Binding **resultbindings) +evalquery(Term *query) { - if(choicestack == nil){ - /* - The goal stack has the original query at the very bottom, protected by a catch frame where the ->goal field is nil. - This makes it so that we can continue until we hit the protective goal, at which point we have solved everything - and to get the result we can unify the original query with the one at the bottom of the stack, to get the bindings - applied. - */ - goalstack = gmalloc(sizeof(Goal)); - goalstack->goal = copyterm(query, nil); - goalstack->module = usermodule; - goalstack->catcher = nil; - goalstack->next = nil; - Goal *protector = gmalloc(sizeof(Goal)); - protector->goal = nil; - protector->module = usermodule; - protector->catcher = mkvariable(L"catch-var"); - protector->next = goalstack; - goalstack = protector; - - /* Now add the actual goals */ - goalstack = addgoals(goalstack, query, usermodule); - - }else{ - goto Backtrack; - } + Binding *replbindings = nil; + goalstack = addgoals(goalstack, query, usermodule); while(goalstack->goal != nil){ Term *goal = goalstack->goal; @@ -101,7 +78,7 @@ Backtrack: } } goalstack = goalstack->next; - unify(query, goalstack->goal, resultbindings); + unify(query, goalstack->goal, &replbindings); return 1; } |