From baea4aa939861fd4efbc71b96f93ba890f01ac40 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 30 Jun 2021 17:48:49 +0000 Subject: Add a standard library with the "builtins" that doesn't really need to be actual builtins --- builtins.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'builtins.c') diff --git a/builtins.c b/builtins.c index 5db5e62..b6031fe 100644 --- a/builtins.c +++ b/builtins.c @@ -4,7 +4,6 @@ #include "dat.h" #include "fns.h" -int builtintrue(Term *, Term *, Goal **, Choicepoint **, Binding **); int builtinfail(Term *, Term *, Goal **, Choicepoint **, Binding **); int builtincall(Term *, Term *, Goal **, Choicepoint **, Binding **); int builtincut(Term *, Term *, Goal **, Choicepoint **, Binding **); @@ -28,8 +27,6 @@ findbuiltin(Term *goal) return nil; } - if(!runestrcmp(name, L"true") && arity == 0) - return builtintrue; if(!runestrcmp(name, L"fail") && arity == 0) return builtinfail; if(!runestrcmp(name, L"call") && arity == 1) @@ -40,17 +37,6 @@ findbuiltin(Term *goal) return nil; } -int -builtintrue(Term *database, Term *goal, Goal **goals, Choicepoint **choicestack, Binding **bindings) -{ - USED(database); - USED(goal); - USED(goals); - USED(choicestack); - USED(bindings); - return 1; -} - int builtinfail(Term *database, Term *goal, Goal **goals, Choicepoint **choicestack, Binding **bindings) { @@ -85,7 +71,11 @@ builtincut(Term *database, Term *goal, Goal **goals, Choicepoint **choicestack, USED(bindings); Choicepoint *cp = *choicestack; - while(cp != nil && cp->id == goal->clausenr) + + /* Cut all choicepoints with an id larger or equal to the goal clause number, since they must have been introduced + after this goal's parent. + */ + while(cp != nil && cp->id >= goal->clausenr) cp = cp->next; *choicestack = cp; return 1; -- cgit v1.2.3