altos/lisp: Use poly stashes for stacks
[fw/altos] / src / lisp / ao_lisp_mem.c
index 53ebf757d25825151d827f1f1b8d9bebc2262262..2599f719f21ad48ab8af6c078c3447261295a49d 100644 (file)
@@ -144,7 +144,7 @@ struct ao_lisp_root {
 
 static struct ao_lisp_cons     *save_cons[2];
 static char                    *save_string[2];
-static ao_poly                 save_poly[2];
+static ao_poly                 save_poly[3];
 
 static const struct ao_lisp_root       ao_lisp_root[] = {
        {
@@ -157,11 +157,11 @@ static const struct ao_lisp_root  ao_lisp_root[] = {
        },
        {
                .type = &ao_lisp_string_type,
-               .addr = (void **) &save_string[0]
+               .addr = (void **) &save_string[0],
        },
        {
                .type = &ao_lisp_string_type,
-               .addr = (void **) &save_string[1]
+               .addr = (void **) &save_string[1],
        },
        {
                .type = NULL,
@@ -171,6 +171,10 @@ static const struct ao_lisp_root   ao_lisp_root[] = {
                .type = NULL,
                .addr = (void **) &save_poly[1]
        },
+       {
+               .type = NULL,
+               .addr = (void **) &save_poly[2]
+       },
        {
                .type = &ao_lisp_atom_type,
                .addr = (void **) &ao_lisp_atoms
@@ -252,23 +256,6 @@ static inline uint16_t pool_offset(void *addr) {
        return ((uint8_t *) addr) - ao_lisp_pool;
 }
 
-/*
- * Convert back and forth between 'poly's used
- * as short addresses in the pool and addresses.
- * These are used in the chunk code.
- */
-static inline ao_poly pool_poly(void *addr) {
-#if DBG_MEM
-       if (!AO_LISP_IS_POOL(addr))
-               ao_lisp_abort();
-#endif
-       return ((uint8_t *) addr) - AO_LISP_POOL_BASE;
-}
-
-static inline void *pool_ref(ao_poly p) {
-       return AO_LISP_POOL_BASE + p;
-}
-
 static inline void mark(uint8_t *tag, int offset) {
        int     byte = offset >> 5;
        int     bit = (offset >> 2) & 7;
@@ -451,6 +438,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
@@ -835,6 +823,20 @@ ao_lisp_cons_fetch(int id)
        return cons;
 }
 
+void
+ao_lisp_poly_stash(int id, ao_poly poly)
+{
+       save_poly[id] = poly;
+}
+
+ao_poly
+ao_lisp_poly_fetch(int id)
+{
+       ao_poly poly = save_poly[id];
+       save_poly[id] = AO_LISP_NIL;
+       return poly;
+}
+
 void
 ao_lisp_string_stash(int id, char *string)
 {
@@ -848,16 +850,4 @@ ao_lisp_string_fetch(int id)
        save_string[id] = NULL;
        return string;
 }
-void
-ao_lisp_poly_stash(int id, ao_poly poly)
-{
-       save_poly[id] = poly;
-}
 
-ao_poly
-ao_lisp_poly_fetch(int id)
-{
-       ao_poly poly = save_poly[id];
-       save_poly[id] = AO_LISP_NIL;
-       return poly;
-}