summaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2021-07-05 16:27:38 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2021-07-05 16:27:38 +0000
commit44ab8a339c78bcc3460d44b2f435116f21faa60a (patch)
treefa512c143c5df81c0c333a187b9083cbac9636f6 /dat.h
parent3f26a0f2a1f699e628136ec5be6178b5ab40fc44 (diff)
First step on modules. Still very very rough.
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h32
1 files changed, 27 insertions, 5 deletions
diff --git a/dat.h b/dat.h
index 574cf4f..288932e 100644
--- a/dat.h
+++ b/dat.h
@@ -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 */