X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=src%2Fprint.c;h=942ad0d783e4c71d93e13b9a3bfc94ce09be6b48;hb=e3dcc1d3966fb95a5a232daa193c6b5d89a06b7e;hp=3a5866ad0f29234031a7b28aec51d60434578582;hpb=58a5ffdfec139a0c9d399f603b77a764ae8607f7;p=muddle-interpreter.git diff --git a/src/print.c b/src/print.c index 3a5866a..942ad0d 100644 --- a/src/print.c +++ b/src/print.c @@ -16,6 +16,7 @@ License along with this file. If not, see . */ +#include "atom.h" #include "print.h" #include "object.h" @@ -39,6 +40,28 @@ print_vector_body (const vector_object * o) } } +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) { @@ -64,6 +87,10 @@ print_object (const object * o) case EVALTYPE_FIX64: 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); @@ -79,7 +106,20 @@ print_object (const object * o) 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"); } }