summaryrefslogtreecommitdiff
path: root/builtins.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2021-06-30 17:48:49 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2021-06-30 17:48:49 +0000
commitbaea4aa939861fd4efbc71b96f93ba890f01ac40 (patch)
tree17258014a63d0c0e8de767bcb31914c6d2cb2b1e /builtins.c
parent50f83a91220940042962fdb55d07bb03991f52be (diff)
Add a standard library with the "builtins" that doesn't really need to be actual builtins
Diffstat (limited to 'builtins.c')
-rw-r--r--builtins.c20
1 files changed, 5 insertions, 15 deletions
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)
@@ -41,17 +38,6 @@ findbuiltin(Term *goal)
}
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)
{
USED(database);
@@ -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;