projects
/
muddle-interpreter.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement NTH.
[muddle-interpreter.git]
/
src
/
main.c
diff --git
a/src/main.c
b/src/main.c
index b57ee6d06bf2ad4b3dcd6ae99d1888e1e0d27c05..5ecbcd8352344a389080641efa68a3063ec79775 100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-1,5
+1,5
@@
/*
/*
-Copyright (C) 2017 Keziah Wesley
+Copyright (C) 2017
-2018
Keziah Wesley
You can redistribute and/or modify this file under the terms of the
GNU Affero General Public License as published by the Free Software
You can redistribute and/or modify this file under the terms of the
GNU Affero General Public License as published by the Free Software
@@
-16,19
+16,26
@@
License along with this file. If not, see
<http://www.gnu.org/licenses/>.
*/
<http://www.gnu.org/licenses/>.
*/
+#include "atom.h"
#include "read.h"
#include "eval.h"
#include "print.h"
#include "object.h"
#include "read.h"
#include "eval.h"
#include "print.h"
#include "object.h"
+#include "oblist.h"
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
// TODO: put these in interpreter-wide ctx object
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
// TODO: put these in interpreter-wide ctx object
-char *pool;
-char *vhp_base;
-char *vhp;
+pool_object *pool;
+pool_ptr ptop;
+object *vhp_base;
+heap_ptr vhp;
+vector_object globals;
+
+// oblists (move to ASOCs once implemented)
+uvector_object root;
// TODO: store these in current PROCESS
frame *cf;
// TODO: store these in current PROCESS
frame *cf;
@@
-49,14
+56,16
@@
enum
READER_OBJCT = 64
};
READER_OBJCT = 64
};
+void init_standard_env ();
+
int
main ()
{
// The REST pool (in low mem).
int
main ()
{
// The REST pool (in low mem).
-
char *pool_base
=
+
pool
=
mmap (0, POOL_OBJCT * sizeof (object), PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
mmap (0, POOL_OBJCT * sizeof (object), PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
- p
ool = pool_base;
+ p
top = 1; // 0 is null
// The CONTROL STACKs (TODO: per-PROCESS).
object *cst_base =
// The CONTROL STACKs (TODO: per-PROCESS).
object *cst_base =
@@
-70,7
+79,7
@@
main ()
vhp_base =
mmap (0, VECTOR_OBJCT * sizeof (object), PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
vhp_base =
mmap (0, VECTOR_OBJCT * sizeof (object), PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- vhp =
vhp_base
;
+ vhp =
1
;
// Reader stack (TODO: dynamically allocate as VECTOR).
object rst_base[READER_OBJCT];
// Reader stack (TODO: dynamically allocate as VECTOR).
object rst_base[READER_OBJCT];
@@
-80,11
+89,14
@@
main ()
// Entire toplevel becomes `for (;;) cf->cont.fn();`
char buf[512];
ssize_t n;
// Entire toplevel becomes `for (;;) cf->cont.fn();`
char buf[512];
ssize_t n;
+ // no GC (leak everything)
+ ptop = 1;
+ vhp = 1;
+ root = oblist_create (13);
+ globals = vector_create (64);
+ init_standard_env ();
while ((n = read (STDIN_FILENO, buf, sizeof (buf))) > 0)
{
while ((n = read (STDIN_FILENO, buf, sizeof (buf))) > 0)
{
- // mock GC (no object persistence)
- pool = pool_base;
- vhp = vhp_base;
// terminate input
assert (buf[n - 1] == '\n');
buf[n - 1] = '\0';
// terminate input
assert (buf[n - 1] == '\n');
buf[n - 1] = '\0';
@@
-99,26
+111,28
@@
main ()
}
assert (p);
if (!st.framelen)
}
assert (p);
if (!st.framelen)
-
continue;
+ continue;
assert (st.framelen == 1);
assert (st.framelen == 1);
- /*
// Eval the thing
// Eval the thing
+ cf->prevcst = cst;
push_frame (eval, new_tuple (st.pos, 1), 0);
push_frame (eval, new_tuple (st.pos, 1), 0);
- while (cf->cont.fn)
+ while (cf->cont.
val.
fn)
{
{
- cf->cont.fn ();
+ cf->cont.
val.
fn ();
}
// Print the thing
print_object (&ret);
}
// Print the thing
print_object (&ret);
- */
- // debugging: print without eval
- print_object (st.pos);
printf ("\n");
printf ("\n");
+ /*
+ // debugging oblists...
+ print_object ((object*) &root);
+ printf ("\n");
+ */
// Loop!
}
munmap (cst_base, STACK_OBJCT * sizeof (object));
munmap (vhp_base, VECTOR_OBJCT * sizeof (object));
// Loop!
}
munmap (cst_base, STACK_OBJCT * sizeof (object));
munmap (vhp_base, VECTOR_OBJCT * sizeof (object));
- munmap (pool
_base
, POOL_OBJCT * sizeof (object));
+ munmap (pool, POOL_OBJCT * sizeof (object));
return 0;
}
return 0;
}