altos/lisp: split set/def. Add def support to lambdas
[fw/altos] / src / lisp / ao_lisp_stack.c
index 9c773e83cef3cf95a61aa14fda5cccd4bce73135..e7c8980189763d7278b0202f93677d83cb3e0bd3 100644 (file)
@@ -12,7 +12,6 @@
  * General Public License for more details.
  */
 
-#define DBG_EVAL 0
 #include "ao_lisp.h"
 
 const struct ao_lisp_type ao_lisp_stack_type;
@@ -104,7 +103,9 @@ ao_lisp_stack_new(void)
 int
 ao_lisp_stack_push(void)
 {
-       struct ao_lisp_stack    *stack = ao_lisp_stack_new();
+       struct ao_lisp_stack    *stack;
+
+       stack = ao_lisp_stack_new();
 
        if (!stack)
                return 0;
@@ -157,18 +158,18 @@ ao_lisp_stack_clear(void)
 }
 
 void
-ao_lisp_stack_print(ao_poly poly)
+ao_lisp_stack_write(ao_poly poly)
 {
        struct ao_lisp_stack *s = ao_lisp_poly_stack(poly);
 
-       if (s->type & AO_LISP_STACK_PRINT) {
-               printf("[recurse...]");
-               return;
-       }
        while (s) {
+               if (s->type & AO_LISP_STACK_PRINT) {
+                       printf("[recurse...]");
+                       return;
+               }
                s->type |= AO_LISP_STACK_PRINT;
                printf("\t[\n");
-               printf("\t\texpr:   "); ao_lisp_poly_print(s->list); printf("\n");
+               printf("\t\texpr:   "); ao_lisp_poly_write(s->list); printf("\n");
                printf("\t\tstate:  %s\n", ao_lisp_state_names[s->state]);
                ao_lisp_error_poly ("values: ", s->values, s->values_tail);
                ao_lisp_error_poly ("sexprs: ", s->sexprs, AO_LISP_NIL);
@@ -242,7 +243,7 @@ ao_lisp_stack_eval(void)
  * it a single argument which is the current continuation
  */
 ao_poly
-ao_lisp_call_cc(struct ao_lisp_cons *cons)
+ao_lisp_do_call_cc(struct ao_lisp_cons *cons)
 {
        struct ao_lisp_stack    *new;
        ao_poly                 v;
@@ -274,6 +275,6 @@ ao_lisp_call_cc(struct ao_lisp_cons *cons)
        cons->cdr = AO_LISP_NIL;
        v = ao_lisp_lambda_eval();
        ao_lisp_stack->sexprs = v;
-       ao_lisp_stack->state = eval_progn;
+       ao_lisp_stack->state = eval_begin;
        return AO_LISP_NIL;
 }