summaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2021-07-06 17:45:15 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2021-07-06 17:45:15 +0000
commit0c45e33c1b8d094353a5585c44179d1818ff6e1e (patch)
tree467a355a30b695f5f1a1093a56b6846b943f6a9d /dat.h
parentbdcc02a5ea2d165c638d667978e8e2cf7462558a (diff)
Group clauses into predicates, and create all valid choicepoints at once. This is wastefull if one branch loops forever, but it is much nicer otherwise, since we know the choicepoints only gets created as long as their head is unifiable with the goal.
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/dat.h b/dat.h
index 484387b..783a785 100644
--- a/dat.h
+++ b/dat.h
@@ -3,6 +3,7 @@ typedef struct Binding Binding;
typedef struct Goal Goal;
typedef struct Choicepoint Choicepoint;
typedef struct Clause Clause;
+typedef struct Predicate Predicate;
typedef struct Module Module;
typedef int (*Builtin)(Term *, Binding **);
@@ -37,7 +38,8 @@ struct Goal
struct Choicepoint
{
Goal *goalstack;
- Clause *retryclause;
+ Clause *alternative;
+ Binding *altbindings;
uvlong id; /* Unique number for each clause. Used to know where to cut to. */
Module *currentmodule;
Choicepoint *next;
@@ -52,11 +54,19 @@ struct Clause
Clause *next;
};
+struct Predicate
+{
+ Rune *name;
+ int arity;
+ Clause *clauses;
+ Predicate *next;
+};
+
struct Module
{
/* What about imports */
Rune *name;
- Clause *clauses;
+ Predicate *predicates;
Module *next;
};