diff options
author | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-05 16:27:38 +0000 |
---|---|---|
committer | Peter Mikkelsen <peter@pmikkelsen.com> | 2021-07-05 16:27:38 +0000 |
commit | 44ab8a339c78bcc3460d44b2f435116f21faa60a (patch) | |
tree | fa512c143c5df81c0c333a187b9083cbac9636f6 /dat.h | |
parent | 3f26a0f2a1f699e628136ec5be6178b5ab40fc44 (diff) |
First step on modules. Still very very rough.
Diffstat (limited to 'dat.h')
-rw-r--r-- | dat.h | 32 |
1 files changed, 27 insertions, 5 deletions
@@ -2,7 +2,9 @@ typedef struct Term Term; typedef struct Binding Binding; typedef struct Goal Goal; typedef struct Choicepoint Choicepoint; -typedef int (*Builtin)(Term *, Term *, Binding **); +typedef struct Clause Clause; +typedef struct Module Module; +typedef int (*Builtin)(Term *, Binding **); struct Term { @@ -36,11 +38,29 @@ struct Goal struct Choicepoint { Goal *goalstack; - Term *retryclause; + Clause *retryclause; uvlong id; /* Unique number for each clause. Used to know where to cut to. */ + Module *currentmodule; Choicepoint *next; }; +struct Clause +{ + Term *head; + Term *body; + uvlong clausenr; + int public; + Clause *next; +}; + +struct Module +{ + /* What about imports */ + Rune *name; + Clause *clauses; + Module *next; +}; + /* Sorted so that a lower value means it comes earlier in the standard ordering */ enum { VariableTerm, @@ -55,7 +75,6 @@ enum { }; int debug; -Term *initgoals; /* Flags */ enum { @@ -66,6 +85,9 @@ enum { int flagdoublequotes; -/* Staate of the running system */ +/* State of the running system */ Choicepoint *choicestack; -Goal *goalstack;
\ No newline at end of file +Goal *goalstack; +Module *modules; +Module *systemmodule; /* The module for the builtins. Everything has access to those */ +Module *usermodule; /* The default module for user defined predicates */ |