#else
#include "ao_lisp_const.h"
#ifndef AO_LISP_POOL
-#define AO_LISP_POOL 1024
+#define AO_LISP_POOL 16384
#endif
extern uint8_t ao_lisp_pool[AO_LISP_POOL];
#endif
static inline void *
ao_lisp_ref(ao_poly poly) {
+ if (poly == 0xBEEF)
+ abort();
if (poly == AO_LISP_NIL)
return NULL;
if (poly & AO_LISP_CONST)
};
struct ao_lisp_frame {
+ uint8_t type;
uint8_t num;
- uint8_t readonly;
ao_poly next;
struct ao_lisp_val vals[];
};
builtin_setq,
builtin_cond,
builtin_print,
+ builtin_patom,
builtin_plus,
builtin_minus,
builtin_times,
builtin_divide,
builtin_mod,
+ builtin_equal,
+ builtin_less,
+ builtin_greater,
+ builtin_less_equal,
+ builtin_greater_equal,
builtin_last
};
#define AO_LISP_OTHER_POLY(other) ((ao_poly)(other) + AO_LISP_OTHER)
+static inline int ao_lisp_poly_base_type(ao_poly poly) {
+ return poly & AO_LISP_TYPE_MASK;
+}
+
static inline int ao_lisp_poly_type(ao_poly poly) {
int type = poly & AO_LISP_TYPE_MASK;
if (type == AO_LISP_OTHER)
}
/* memory functions */
-void
+/* returns 1 if the object was already marked */
+int
ao_lisp_mark(const struct ao_lisp_type *type, void *addr);
/* returns 1 if the object was already marked */
void *
ao_lisp_move_map(void *addr);
-void *
-ao_lisp_move(const struct ao_lisp_type *type, void *addr);
+/* returns 1 if the object was already moved */
+int
+ao_lisp_move(const struct ao_lisp_type *type, void **ref);
-/* returns NULL if the object was already moved */
-void *
-ao_lisp_move_memory(void *addr, int size);
+/* returns 1 if the object was already moved */
+int
+ao_lisp_move_memory(void **ref, int size);
void *
ao_lisp_alloc(int size);
int
ao_lisp_root_add(const struct ao_lisp_type *type, void *addr);
+int
+ao_lisp_root_poly_add(ao_poly *p);
+
void
ao_lisp_root_clear(void *addr);
void
ao_lisp_cons_print(ao_poly);
+void
+ao_lisp_cons_patom(ao_poly);
+
/* string */
extern const struct ao_lisp_type ao_lisp_string_type;
void
ao_lisp_string_print(ao_poly s);
+void
+ao_lisp_string_patom(ao_poly s);
+
/* atom */
extern const struct ao_lisp_type ao_lisp_atom_type;
ao_lisp_int_print(ao_poly i);
/* prim */
-ao_poly
+void
ao_lisp_poly_print(ao_poly p);
void
-ao_lisp_poly_mark(ao_poly p);
+ao_lisp_poly_patom(ao_poly p);
-ao_poly
-ao_lisp_poly_move(ao_poly p);
+int
+ao_lisp_poly_mark(ao_poly p, uint8_t note_cons);
+
+/* returns 1 if the object has already been moved */
+int
+ao_lisp_poly_move(ao_poly *p, uint8_t note_cons);
/* eval */
+
ao_poly
ao_lisp_eval(ao_poly p);
ao_lisp_frame_ref(struct ao_lisp_frame *frame, ao_poly atom);
struct ao_lisp_frame *
-ao_lisp_frame_new(int num, int readonly);
+ao_lisp_frame_new(int num);
struct ao_lisp_frame *
ao_lisp_frame_add(struct ao_lisp_frame *frame, ao_poly atom, ao_poly val);