2 Copyright (C) 2017-2018 Keziah Wesley
4 You can redistribute and/or modify this file under the terms of the
5 GNU Affero General Public License as published by the Free Software
6 Foundation, either version 3 of the License, or (at your option) any
9 This file is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Affero General Public License for more details.
14 You should have received a copy of the GNU Affero General Public
15 License along with this file. If not, see
16 <http://www.gnu.org/licenses/>.
29 // TODO: put these in interpreter-wide ctx object
35 // oblists (move to ASOCs once implemented)
38 // TODO: store these in current PROCESS
43 // Define the address spaces.
46 // Max objects that can be in linked lists (must be < 2^32).
48 // Max size, in objects, of control stack segment.
50 // Max size, in objects, of VECTOR heap.
52 // Max objects reader can handle at once.
53 // TODO: allocate as VECTOR and eliminate this arbitrary limit
60 // The REST pool (in low mem).
62 mmap (0, POOL_OBJCT * sizeof (object), PROT_READ | PROT_WRITE,
63 MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT, -1, 0);
64 ptop = 1; // 0 is null
66 // The CONTROL STACKs (TODO: per-PROCESS).
68 mmap (0, STACK_OBJCT * sizeof (object), PROT_READ | PROT_WRITE,
69 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
72 cst += sizeof (frame) / sizeof (object);
76 mmap (0, VECTOR_OBJCT * sizeof (object), PROT_READ | PROT_WRITE,
77 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
80 // Reader stack (TODO: dynamically allocate as VECTOR).
81 object rst_base[READER_OBJCT];
82 object *rst = rst_base + READER_OBJCT;
84 // TODO: push frames for `<REPEAT <PRINT <EVAL <READ>>>>`.
85 // Entire toplevel becomes `for (;;) cf->cont.fn();`
88 while ((n = read (STDIN_FILENO, buf, sizeof (buf))) > 0)
90 // mock GC (no object persistence)
93 root = oblist_create (13);
95 assert (buf[n - 1] == '\n');
104 p = read_token (p, &st);
109 assert (st.framelen == 1);
112 push_frame (eval, new_tuple (st.pos, 1), 0);
113 while (cf->cont.val.fn)
121 // debugging oblists...
122 print_object ((object*) &root);
128 munmap (cst_base, STACK_OBJCT * sizeof (object));
129 munmap (vhp_base, VECTOR_OBJCT * sizeof (object));
130 munmap (pool, POOL_OBJCT * sizeof (object));