altos/lisp: Eliminate compiler warning about array bounds at -O3
[fw/altos] / src / lisp / ao_lisp.h
1 /*
2  * Copyright © 2016 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program 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  * General Public License for more details.
13  */
14
15 #ifndef _AO_LISP_H_
16 #define _AO_LISP_H_
17
18 #include <stdint.h>
19 #include <string.h>
20 //#include <stdio.h>
21 #include <ao_lisp_os.h>
22
23 typedef uint16_t        ao_poly;
24 typedef int16_t         ao_signed_poly;
25
26 #ifdef AO_LISP_SAVE
27
28 struct ao_lisp_os_save {
29         ao_poly         atoms;
30         ao_poly         globals;
31         uint16_t        const_checksum;
32         uint16_t        const_checksum_inv;
33 };
34
35 #define AO_LISP_POOL_EXTRA      (sizeof(struct ao_lisp_os_save))
36 #define AO_LISP_POOL    ((int) (AO_LISP_POOL_TOTAL - AO_LISP_POOL_EXTRA))
37
38 int
39 ao_lisp_os_save(void);
40
41 int
42 ao_lisp_os_restore_save(struct ao_lisp_os_save *save, int offset);
43
44 int
45 ao_lisp_os_restore(void);
46
47 #endif
48
49 #ifdef AO_LISP_MAKE_CONST
50 #define AO_LISP_POOL_CONST      16384
51 extern uint8_t ao_lisp_const[AO_LISP_POOL_CONST];
52 #define ao_lisp_pool ao_lisp_const
53 #define AO_LISP_POOL AO_LISP_POOL_CONST
54
55 #define _atom(n) ao_lisp_atom_poly(ao_lisp_atom_intern(n))
56
57 #define _ao_lisp_atom_quote     _atom("quote")
58 #define _ao_lisp_atom_set       _atom("set")
59 #define _ao_lisp_atom_setq      _atom("setq")
60 #define _ao_lisp_atom_t         _atom("t")
61 #define _ao_lisp_atom_car       _atom("car")
62 #define _ao_lisp_atom_cdr       _atom("cdr")
63 #define _ao_lisp_atom_cons      _atom("cons")
64 #define _ao_lisp_atom_last      _atom("last")
65 #define _ao_lisp_atom_length    _atom("length")
66 #define _ao_lisp_atom_cond      _atom("cond")
67 #define _ao_lisp_atom_lambda    _atom("lambda")
68 #define _ao_lisp_atom_led       _atom("led")
69 #define _ao_lisp_atom_delay     _atom("delay")
70 #define _ao_lisp_atom_pack      _atom("pack")
71 #define _ao_lisp_atom_unpack    _atom("unpack")
72 #define _ao_lisp_atom_flush     _atom("flush")
73 #define _ao_lisp_atom_eval      _atom("eval")
74 #define _ao_lisp_atom_read      _atom("read")
75 #define _ao_lisp_atom_eof       _atom("eof")
76 #define _ao_lisp_atom_save      _atom("save")
77 #define _ao_lisp_atom_restore   _atom("restore")
78 #else
79 #include "ao_lisp_const.h"
80 #ifndef AO_LISP_POOL
81 #define AO_LISP_POOL    3072
82 #endif
83 extern uint8_t          ao_lisp_pool[AO_LISP_POOL + AO_LISP_POOL_EXTRA];
84 #endif
85
86 /* Primitive types */
87 #define AO_LISP_CONS            0
88 #define AO_LISP_INT             1
89 #define AO_LISP_STRING          2
90 #define AO_LISP_OTHER           3
91
92 #define AO_LISP_TYPE_MASK       0x0003
93 #define AO_LISP_TYPE_SHIFT      2
94 #define AO_LISP_REF_MASK        0x7ffc
95 #define AO_LISP_CONST           0x8000
96
97 /* These have a type value at the start of the struct */
98 #define AO_LISP_ATOM            4
99 #define AO_LISP_BUILTIN         5
100 #define AO_LISP_FRAME           6
101 #define AO_LISP_LAMBDA          7
102 #define AO_LISP_NUM_TYPE        8
103
104 #define AO_LISP_NIL     0
105
106 extern uint16_t         ao_lisp_top;
107
108 #define AO_LISP_OOM             0x01
109 #define AO_LISP_DIVIDE_BY_ZERO  0x02
110 #define AO_LISP_INVALID         0x04
111 #define AO_LISP_UNDEFINED       0x08
112 #define AO_LISP_EOF             0x10
113
114 extern uint8_t          ao_lisp_exception;
115
116 static inline int
117 ao_lisp_is_const(ao_poly poly) {
118         return poly & AO_LISP_CONST;
119 }
120
121 #define AO_LISP_IS_CONST(a)     (ao_lisp_const <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_lisp_const + AO_LISP_POOL_CONST)
122 #define AO_LISP_IS_POOL(a)      (ao_lisp_pool <= ((uint8_t *) (a)) && ((uint8_t *) (a)) < ao_lisp_pool + AO_LISP_POOL)
123
124 void *
125 ao_lisp_ref(ao_poly poly);
126
127 ao_poly
128 ao_lisp_poly(const void *addr, ao_poly type);
129
130 struct ao_lisp_type {
131         int     (*size)(void *addr);
132         void    (*mark)(void *addr);
133         void    (*move)(void *addr);
134         char    name[];
135 };
136
137 struct ao_lisp_cons {
138         ao_poly         car;
139         ao_poly         cdr;
140 };
141
142 struct ao_lisp_atom {
143         uint8_t         type;
144         uint8_t         pad[1];
145         ao_poly         next;
146         char            name[];
147 };
148
149 struct ao_lisp_val {
150         ao_poly         atom;
151         ao_poly         val;
152 };
153
154 struct ao_lisp_frame {
155         uint8_t                 type;
156         uint8_t                 _num;
157         ao_poly                 prev;
158         struct ao_lisp_val      vals[];
159 };
160
161 #define AO_LISP_FRAME_NUM_MASK  0x7f
162
163 /* Set when the frame escapes the lambda */
164 #define AO_LISP_FRAME_MARK      0x80
165
166 static inline int ao_lisp_frame_num(struct ao_lisp_frame *f) {
167         if (f->_num == 0xff)
168                 ao_lisp_abort();
169         return f->_num & AO_LISP_FRAME_NUM_MASK;
170 }
171
172 static inline int ao_lisp_frame_marked(struct ao_lisp_frame *f) {
173         if (f->_num == 0xff)
174                 ao_lisp_abort();
175         return f->_num & AO_LISP_FRAME_MARK;
176 }
177
178 static inline struct ao_lisp_frame *
179 ao_lisp_poly_frame(ao_poly poly) {
180         struct ao_lisp_frame *frame = ao_lisp_ref(poly);
181         if (frame && frame->_num == 0xff)
182                 ao_lisp_abort();
183         return ao_lisp_ref(poly);
184 }
185
186 static inline ao_poly
187 ao_lisp_frame_poly(struct ao_lisp_frame *frame) {
188         return ao_lisp_poly(frame, AO_LISP_OTHER);
189 }
190
191 enum eval_state {
192         eval_sexpr,             /* Evaluate an sexpr */
193         eval_val,               /* Value computed */
194         eval_formal,            /* Formal computed */
195         eval_exec,              /* Start a lambda evaluation */
196         eval_cond,              /* Start next cond clause */
197         eval_cond_test,         /* Check cond condition */
198         eval_progn,             /* Start next progn entry */
199         eval_while,             /* Start while condition */
200         eval_while_test,        /* Check while condition */
201         eval_macro,             /* Finished with macro generation */
202 };
203
204 struct ao_lisp_stack {
205         uint8_t                 state;          /* enum eval_state */
206         ao_poly                 prev;           /* previous stack frame */
207         ao_poly                 sexprs;         /* expressions to evaluate */
208         ao_poly                 values;         /* values computed */
209         ao_poly                 values_tail;    /* end of the values list for easy appending */
210         ao_poly                 frame;          /* current lookup frame */
211         ao_poly                 list;           /* most recent function call */
212 };
213
214 static inline struct ao_lisp_stack *
215 ao_lisp_poly_stack(ao_poly p)
216 {
217         return ao_lisp_ref(p);
218 }
219
220 static inline ao_poly
221 ao_lisp_stack_poly(struct ao_lisp_stack *stack)
222 {
223         return ao_lisp_poly(stack, AO_LISP_OTHER);
224 }
225
226 extern struct ao_lisp_stack     *ao_lisp_stack;
227 extern struct ao_lisp_stack     *ao_lisp_stack_free_list;
228 extern ao_poly                  ao_lisp_v;
229
230 #define AO_LISP_FUNC_LAMBDA     0
231 #define AO_LISP_FUNC_NLAMBDA    1
232 #define AO_LISP_FUNC_MACRO      2
233 #define AO_LISP_FUNC_LEXPR      3
234
235 #define AO_LISP_FUNC_FREE_ARGS  0x80
236 #define AO_LISP_FUNC_MASK       0x7f
237
238 #define AO_LISP_FUNC_F_LAMBDA   (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_LAMBDA)
239 #define AO_LISP_FUNC_F_NLAMBDA  (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_NLAMBDA)
240 #define AO_LISP_FUNC_F_MACRO    (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_MACRO)
241 #define AO_LISP_FUNC_F_LEXPR    (AO_LISP_FUNC_FREE_ARGS | AO_LISP_FUNC_LEXPR)
242
243 struct ao_lisp_builtin {
244         uint8_t         type;
245         uint8_t         args;
246         uint16_t        func;
247 };
248
249 enum ao_lisp_builtin_id {
250         builtin_eval,
251         builtin_read,
252         builtin_lambda,
253         builtin_lexpr,
254         builtin_nlambda,
255         builtin_macro,
256         builtin_car,
257         builtin_cdr,
258         builtin_cons,
259         builtin_last,
260         builtin_length,
261         builtin_quote,
262         builtin_set,
263         builtin_setq,
264         builtin_cond,
265         builtin_progn,
266         builtin_while,
267         builtin_print,
268         builtin_patom,
269         builtin_plus,
270         builtin_minus,
271         builtin_times,
272         builtin_divide,
273         builtin_mod,
274         builtin_equal,
275         builtin_less,
276         builtin_greater,
277         builtin_less_equal,
278         builtin_greater_equal,
279         builtin_pack,
280         builtin_unpack,
281         builtin_flush,
282         builtin_delay,
283         builtin_led,
284         builtin_save,
285         builtin_restore,
286         _builtin_last
287 };
288
289 typedef ao_poly (*ao_lisp_func_t)(struct ao_lisp_cons *cons);
290
291 extern const ao_lisp_func_t     ao_lisp_builtins[];
292
293 static inline ao_lisp_func_t
294 ao_lisp_func(struct ao_lisp_builtin *b)
295 {
296         return ao_lisp_builtins[b->func];
297 }
298
299 struct ao_lisp_lambda {
300         uint8_t         type;
301         uint8_t         args;
302         ao_poly         code;
303         ao_poly         frame;
304 };
305
306 static inline struct ao_lisp_lambda *
307 ao_lisp_poly_lambda(ao_poly poly)
308 {
309         return ao_lisp_ref(poly);
310 }
311
312 static inline ao_poly
313 ao_lisp_lambda_poly(struct ao_lisp_lambda *lambda)
314 {
315         return ao_lisp_poly(lambda, AO_LISP_OTHER);
316 }
317
318 static inline void *
319 ao_lisp_poly_other(ao_poly poly) {
320         return ao_lisp_ref(poly);
321 }
322
323 static inline uint8_t
324 ao_lisp_other_type(void *other) {
325         return *((uint8_t *) other);
326 }
327
328 static inline ao_poly
329 ao_lisp_other_poly(const void *other)
330 {
331         return ao_lisp_poly(other, AO_LISP_OTHER);
332 }
333
334 static inline int
335 ao_lisp_size_round(int size)
336 {
337         return (size + 3) & ~3;
338 }
339
340 static inline int
341 ao_lisp_size(const struct ao_lisp_type *type, void *addr)
342 {
343         return ao_lisp_size_round(type->size(addr));
344 }
345
346 #define AO_LISP_OTHER_POLY(other) ((ao_poly)(other) + AO_LISP_OTHER)
347
348 static inline int ao_lisp_poly_base_type(ao_poly poly) {
349         return poly & AO_LISP_TYPE_MASK;
350 }
351
352 static inline int ao_lisp_poly_type(ao_poly poly) {
353         int     type = poly & AO_LISP_TYPE_MASK;
354         if (type == AO_LISP_OTHER)
355                 return ao_lisp_other_type(ao_lisp_poly_other(poly));
356         return type;
357 }
358
359 static inline struct ao_lisp_cons *
360 ao_lisp_poly_cons(ao_poly poly)
361 {
362         return ao_lisp_ref(poly);
363 }
364
365 static inline ao_poly
366 ao_lisp_cons_poly(struct ao_lisp_cons *cons)
367 {
368         return ao_lisp_poly(cons, AO_LISP_CONS);
369 }
370
371 static inline int
372 ao_lisp_poly_int(ao_poly poly)
373 {
374         return (int) ((ao_signed_poly) poly >> AO_LISP_TYPE_SHIFT);
375 }
376
377 static inline ao_poly
378 ao_lisp_int_poly(int i)
379 {
380         return ((ao_poly) i << 2) | AO_LISP_INT;
381 }
382
383 static inline char *
384 ao_lisp_poly_string(ao_poly poly)
385 {
386         return ao_lisp_ref(poly);
387 }
388
389 static inline ao_poly
390 ao_lisp_string_poly(char *s)
391 {
392         return ao_lisp_poly(s, AO_LISP_STRING);
393 }
394
395 static inline struct ao_lisp_atom *
396 ao_lisp_poly_atom(ao_poly poly)
397 {
398         return ao_lisp_ref(poly);
399 }
400
401 static inline ao_poly
402 ao_lisp_atom_poly(struct ao_lisp_atom *a)
403 {
404         return ao_lisp_poly(a, AO_LISP_OTHER);
405 }
406
407 static inline struct ao_lisp_builtin *
408 ao_lisp_poly_builtin(ao_poly poly)
409 {
410         return ao_lisp_ref(poly);
411 }
412
413 static inline ao_poly
414 ao_lisp_builtin_poly(struct ao_lisp_builtin *b)
415 {
416         return ao_lisp_poly(b, AO_LISP_OTHER);
417 }
418
419 /* memory functions */
420
421 extern int ao_lisp_collects[2];
422 extern int ao_lisp_freed[2];
423 extern int ao_lisp_loops[2];
424
425 /* returns 1 if the object was already marked */
426 int
427 ao_lisp_mark(const struct ao_lisp_type *type, void *addr);
428
429 /* returns 1 if the object was already marked */
430 int
431 ao_lisp_mark_memory(const struct ao_lisp_type *type, void *addr);
432
433 void *
434 ao_lisp_move_map(void *addr);
435
436 /* returns 1 if the object was already moved */
437 int
438 ao_lisp_move(const struct ao_lisp_type *type, void **ref);
439
440 /* returns 1 if the object was already moved */
441 int
442 ao_lisp_move_memory(const struct ao_lisp_type *type, void **ref);
443
444 void *
445 ao_lisp_alloc(int size);
446
447 #define AO_LISP_COLLECT_FULL            1
448 #define AO_LISP_COLLECT_INCREMENTAL     0
449
450 int
451 ao_lisp_collect(uint8_t style);
452
453 void
454 ao_lisp_cons_stash(int id, struct ao_lisp_cons *cons);
455
456 struct ao_lisp_cons *
457 ao_lisp_cons_fetch(int id);
458
459 void
460 ao_lisp_string_stash(int id, char *string);
461
462 char *
463 ao_lisp_string_fetch(int id);
464
465 void
466 ao_lisp_poly_stash(int id, ao_poly poly);
467
468 ao_poly
469 ao_lisp_poly_fetch(int id);
470
471 /* cons */
472 extern const struct ao_lisp_type ao_lisp_cons_type;
473
474 struct ao_lisp_cons *
475 ao_lisp_cons_cons(ao_poly car, struct ao_lisp_cons *cdr);
476
477 extern struct ao_lisp_cons *ao_lisp_cons_free_list;
478
479 void
480 ao_lisp_cons_free(struct ao_lisp_cons *cons);
481
482 void
483 ao_lisp_cons_print(ao_poly);
484
485 void
486 ao_lisp_cons_patom(ao_poly);
487
488 int
489 ao_lisp_cons_length(struct ao_lisp_cons *cons);
490
491 /* string */
492 extern const struct ao_lisp_type ao_lisp_string_type;
493
494 char *
495 ao_lisp_string_copy(char *a);
496
497 char *
498 ao_lisp_string_cat(char *a, char *b);
499
500 ao_poly
501 ao_lisp_string_pack(struct ao_lisp_cons *cons);
502
503 ao_poly
504 ao_lisp_string_unpack(char *a);
505
506 void
507 ao_lisp_string_print(ao_poly s);
508
509 void
510 ao_lisp_string_patom(ao_poly s);
511
512 /* atom */
513 extern const struct ao_lisp_type ao_lisp_atom_type;
514
515 extern struct ao_lisp_atom      *ao_lisp_atoms;
516 extern struct ao_lisp_frame     *ao_lisp_frame_global;
517 extern struct ao_lisp_frame     *ao_lisp_frame_current;
518
519 void
520 ao_lisp_atom_print(ao_poly a);
521
522 struct ao_lisp_atom *
523 ao_lisp_atom_intern(char *name);
524
525 ao_poly *
526 ao_lisp_atom_ref(struct ao_lisp_frame *frame, ao_poly atom);
527
528 ao_poly
529 ao_lisp_atom_get(ao_poly atom);
530
531 ao_poly
532 ao_lisp_atom_set(ao_poly atom, ao_poly val);
533
534 /* int */
535 void
536 ao_lisp_int_print(ao_poly i);
537
538 /* prim */
539 void
540 ao_lisp_poly_print(ao_poly p);
541
542 void
543 ao_lisp_poly_patom(ao_poly p);
544
545 int
546 ao_lisp_poly_mark(ao_poly p, uint8_t note_cons);
547
548 /* returns 1 if the object has already been moved */
549 int
550 ao_lisp_poly_move(ao_poly *p, uint8_t note_cons);
551
552 /* eval */
553
554 void
555 ao_lisp_eval_clear_globals(void);
556
557 int
558 ao_lisp_eval_restart(void);
559
560 ao_poly
561 ao_lisp_eval(ao_poly p);
562
563 ao_poly
564 ao_lisp_set_cond(struct ao_lisp_cons *cons);
565
566 /* builtin */
567 void
568 ao_lisp_builtin_print(ao_poly b);
569
570 extern const struct ao_lisp_type ao_lisp_builtin_type;
571
572 /* Check argument count */
573 ao_poly
574 ao_lisp_check_argc(ao_poly name, struct ao_lisp_cons *cons, int min, int max);
575
576 /* Check argument type */
577 ao_poly
578 ao_lisp_check_argt(ao_poly name, struct ao_lisp_cons *cons, int argc, int type, int nil_ok);
579
580 /* Fetch an arg (nil if off the end) */
581 ao_poly
582 ao_lisp_arg(struct ao_lisp_cons *cons, int argc);
583
584 char *
585 ao_lisp_args_name(uint8_t args);
586
587 /* read */
588 extern struct ao_lisp_cons      *ao_lisp_read_cons;
589 extern struct ao_lisp_cons      *ao_lisp_read_cons_tail;
590 extern struct ao_lisp_cons      *ao_lisp_read_stack;
591
592 ao_poly
593 ao_lisp_read(void);
594
595 /* rep */
596 ao_poly
597 ao_lisp_read_eval_print(void);
598
599 /* frame */
600 extern const struct ao_lisp_type ao_lisp_frame_type;
601
602 #define AO_LISP_FRAME_FREE      4
603
604 extern struct ao_lisp_frame     *ao_lisp_frame_free_list[AO_LISP_FRAME_FREE];
605
606 ao_poly
607 ao_lisp_frame_mark(struct ao_lisp_frame *frame);
608
609 ao_poly *
610 ao_lisp_frame_ref(struct ao_lisp_frame *frame, ao_poly atom);
611
612 struct ao_lisp_frame *
613 ao_lisp_frame_new(int num);
614
615 void
616 ao_lisp_frame_free(struct ao_lisp_frame *frame);
617
618 int
619 ao_lisp_frame_add(struct ao_lisp_frame **frame, ao_poly atom, ao_poly val);
620
621 void
622 ao_lisp_frame_print(ao_poly p);
623
624 /* lambda */
625 extern const struct ao_lisp_type ao_lisp_lambda_type;
626
627 struct ao_lisp_lambda *
628 ao_lisp_lambda_new(ao_poly cons);
629
630 void
631 ao_lisp_lambda_print(ao_poly lambda);
632
633 ao_poly
634 ao_lisp_lambda(struct ao_lisp_cons *cons);
635
636 ao_poly
637 ao_lisp_lexpr(struct ao_lisp_cons *cons);
638
639 ao_poly
640 ao_lisp_nlambda(struct ao_lisp_cons *cons);
641
642 ao_poly
643 ao_lisp_macro(struct ao_lisp_cons *cons);
644
645 ao_poly
646 ao_lisp_lambda_eval(void);
647
648 /* save */
649
650 ao_poly
651 ao_lisp_save(struct ao_lisp_cons *cons);
652
653 ao_poly
654 ao_lisp_restore(struct ao_lisp_cons *cons);
655
656 /* error */
657
658 extern const struct ao_lisp_type ao_lisp_stack_type;
659
660 void
661 ao_lisp_stack_print(void);
662
663 ao_poly
664 ao_lisp_error(int error, char *format, ...);
665
666 /* debugging macros */
667
668 #if DBG_EVAL
669 #define DBG_CODE        1
670 int ao_lisp_stack_depth;
671 #define DBG_DO(a)       a
672 #define DBG_INDENT()    do { int _s; for(_s = 0; _s < ao_lisp_stack_depth; _s++) printf("  "); } while(0)
673 #define DBG_IN()        (++ao_lisp_stack_depth)
674 #define DBG_OUT()       (--ao_lisp_stack_depth)
675 #define DBG_RESET()     (ao_lisp_stack_depth = 0)
676 #define DBG(...)        printf(__VA_ARGS__)
677 #define DBGI(...)       do { DBG("%4d: ", __LINE__); DBG_INDENT(); DBG(__VA_ARGS__); } while (0)
678 #define DBG_CONS(a)     ao_lisp_cons_print(ao_lisp_cons_poly(a))
679 #define DBG_POLY(a)     ao_lisp_poly_print(a)
680 #define OFFSET(a)       ((a) ? (int) ((uint8_t *) a - ao_lisp_pool) : -1)
681 #define DBG_STACK()     ao_lisp_stack_print()
682 static inline void
683 ao_lisp_frames_dump(void)
684 {
685         struct ao_lisp_stack *s;
686         DBGI(".. current frame: "); DBG_POLY(ao_lisp_frame_poly(ao_lisp_frame_current)); DBG("\n");
687         for (s = ao_lisp_stack; s; s = ao_lisp_poly_stack(s->prev)) {
688                 DBGI(".. stack frame: "); DBG_POLY(s->frame); DBG("\n");
689         }
690 }
691 #define DBG_FRAMES()    ao_lisp_frames_dump()
692 #else
693 #define DBG_DO(a)
694 #define DBG_INDENT()
695 #define DBG_IN()
696 #define DBG_OUT()
697 #define DBG(...)
698 #define DBGI(...)
699 #define DBG_CONS(a)
700 #define DBG_POLY(a)
701 #define DBG_RESET()
702 #define DBG_STACK()
703 #define DBG_FRAMES()
704 #endif
705
706 #define DBG_MEM         0
707 #define DBG_MEM_START   1
708
709 #if DBG_MEM
710
711 #include <assert.h>
712 extern int dbg_move_depth;
713 #define MDBG_DUMP 1
714 #define MDBG_OFFSET(a)  ((int) ((uint8_t *) (a) - ao_lisp_pool))
715
716 extern int dbg_mem;
717
718 #define MDBG_DO(a)      a
719 #define MDBG_MOVE(...) do { if (dbg_mem) { int d; for (d = 0; d < dbg_move_depth; d++) printf ("  "); printf(__VA_ARGS__); } } while (0)
720 #define MDBG_MORE(...) do { if (dbg_mem) printf(__VA_ARGS__); } while (0)
721 #define MDBG_MOVE_IN()  (dbg_move_depth++)
722 #define MDBG_MOVE_OUT() (assert(--dbg_move_depth >= 0))
723
724 #else
725
726 #define MDBG_DO(a)
727 #define MDBG_MOVE(...)
728 #define MDBG_MORE(...)
729 #define MDBG_MOVE_IN()
730 #define MDBG_MOVE_OUT()
731
732 #endif
733
734 #endif /* _AO_LISP_H_ */