<http://www.gnu.org/licenses/>.
*/
+#include "atom.h"
#include "print.h"
#include "object.h"
static void
print_vector_body (const vector_object * o)
{
- const object *p = HEAP_OBJECT (o->body);
+ const object *p = HEAP_OBJECT (o->val.body);
if (!p)
return;
- if (o->len)
+ if (o->val.len)
print_object (&p[0]);
- for (uint32_t i = 1; i < o->len; i++)
+ for (uint32_t i = 1; i < o->val.len; i++)
{
printf (" ");
print_object (&p[i]);
}
}
+static void
+print_uvector_body (const uvector_object * o)
+{
+ const uv_val *p = UV_VAL (o->val.body);
+ if (!p)
+ return;
+ pool_object x;
+ x.type = utype (o);
+ x.rest = 0;
+ if (o->val.len)
+ {
+ x.val = p[0];
+ print_object ((object *) & x);
+ }
+ for (uint32_t i = 1; i < o->val.len; i++)
+ {
+ printf (" ");
+ x.val = p[i];
+ print_object ((object *) & x);
+ }
+}
+
static void
print_list_body (const list_object * o)
{
- const pool_object *p = POOL_OBJECT (o->head);
+ const pool_object *p = POOL_OBJECT (o->val.head);
if (!p)
return;
print_object ((const object *) p);
switch (o->type)
{
case EVALTYPE_FIX32:
- printf ("%d", o->fix32.val);
+ printf ("%d", o->fix32.val.n);
break;
case EVALTYPE_FIX64:
- printf ("%ld", o->fix64.val);
+ printf ("%ld", o->fix64.val.n);
break;
+ case EVALTYPE_FALSE:
+ // for now, handle non-primtype print as special case (cf. OBLIST)
+ printf ("#FALSE ");
+ // FALLTHROUGH
case EVALTYPE_LIST:
printf ("(");
print_list_body (&o->list);
print_vector_body (&o->vector);
printf ("]");
break;
+ case EVALTYPE_OBLIST:
+ // for now, handle non-primtype print as special case
+ printf ("#OBLIST ");
+ // FALLTHROUGH
+ case EVALTYPE_UVECTOR:
+ printf ("![");
+ print_uvector_body (&o->uvector);
+ printf ("!]");
+ break;
+ case EVALTYPE_ATOM:
+ printf ("%s", atom_pname (o->atom));
+ break;
default:
+ fprintf (stderr, "Tried to print the unprintable: 0x%x\n", o->type);
assert (0 && "I don't know how to print that");
}
}