X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Flisp%2Fao_lisp_poly.c;h=9717fd73131b30712bf7a033f874417b8016034c;hb=7b99963e13f1cf3136c67521c851827377790a06;hp=bfd75ae3b629a1ad9e235277418f3d528e73d6a1;hpb=426f172d92cdef177150f990c4f52b0223a5f6f7;p=fw%2Faltos diff --git a/src/lisp/ao_lisp_poly.c b/src/lisp/ao_lisp_poly.c index bfd75ae3..9717fd73 100644 --- a/src/lisp/ao_lisp_poly.c +++ b/src/lisp/ao_lisp_poly.c @@ -84,3 +84,21 @@ ao_lisp_poly_patom(ao_poly p) f->patom(p); } +void * +ao_lisp_ref(ao_poly poly) { + if (poly == AO_LISP_NIL) + return NULL; + if (poly & AO_LISP_CONST) + return (void *) (AO_LISP_CONST_BASE + (poly & AO_LISP_REF_MASK)); + return (void *) (AO_LISP_POOL_BASE + (poly & AO_LISP_REF_MASK)); +} + +ao_poly +ao_lisp_poly(const void *addr, ao_poly type) { + const uint8_t *a = addr; + if (a == NULL) + return AO_LISP_NIL; + if (AO_LISP_IS_CONST(a)) + return AO_LISP_CONST | (a - AO_LISP_CONST_BASE) | type; + return (a - AO_LISP_POOL_BASE) | type; +}