summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_mem.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-18 19:04:05 -0800
committerKeith Packard <keithp@keithp.com>2017-02-20 11:16:52 -0800
commite600fc409c577eec02af612a36431c477a9c875e (patch)
tree6ad8dee3419084c6bfd90a93017aed0330c4e476 /src/lisp/ao_lisp_mem.c
parent2cc8ca2b781be0a6e7ce14405eb4611bc00a3a3e (diff)
altos/lisp: Add continuations
This provides call/cc and makes 'stacks' visible to the application. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_mem.c')
-rw-r--r--src/lisp/ao_lisp_mem.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lisp/ao_lisp_mem.c b/src/lisp/ao_lisp_mem.c
index 12a5ba55..0dfad1d7 100644
--- a/src/lisp/ao_lisp_mem.c
+++ b/src/lisp/ao_lisp_mem.c
@@ -144,6 +144,7 @@ struct ao_lisp_root {
static struct ao_lisp_cons *save_cons[2];
static char *save_string[2];
+static struct ao_lisp_stack *save_stack[3];
static ao_poly save_poly[2];
static const struct ao_lisp_root ao_lisp_root[] = {
@@ -156,6 +157,18 @@ static const struct ao_lisp_root ao_lisp_root[] = {
.addr = (void **) &save_cons[1],
},
{
+ .type = &ao_lisp_stack_type,
+ .addr = (void **) &save_stack[0]
+ },
+ {
+ .type = &ao_lisp_stack_type,
+ .addr = (void **) &save_stack[1]
+ },
+ {
+ .type = &ao_lisp_stack_type,
+ .addr = (void **) &save_stack[2]
+ },
+ {
.type = &ao_lisp_string_type,
.addr = (void **) &save_string[0]
},
@@ -434,6 +447,7 @@ static const struct ao_lisp_type const *ao_lisp_types[AO_LISP_NUM_TYPE] = {
[AO_LISP_BUILTIN] = &ao_lisp_builtin_type,
[AO_LISP_FRAME] = &ao_lisp_frame_type,
[AO_LISP_LAMBDA] = &ao_lisp_lambda_type,
+ [AO_LISP_STACK] = &ao_lisp_stack_type,
};
static int
@@ -819,6 +833,20 @@ ao_lisp_cons_fetch(int id)
}
void
+ao_lisp_stack_stash(int id, struct ao_lisp_stack *stack)
+{
+ save_stack[id] = stack;
+}
+
+struct ao_lisp_stack *
+ao_lisp_stack_fetch(int id)
+{
+ struct ao_lisp_stack *stack = save_stack[id];
+ save_stack[id] = NULL;
+ return stack;
+}
+
+void
ao_lisp_string_stash(int id, char *string)
{
save_string[id] = string;