Implement OBLISTs
[muddle-interpreter.git] / src / print.c
index 3a5866ad0f29234031a7b28aec51d60434578582..02456bc6e958614d282a5cd21412f87fac7740ca 100644 (file)
@@ -16,6 +16,7 @@ License along with this file. If not, see
 <http://www.gnu.org/licenses/>.
 */
 
+#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)
 {
@@ -79,7 +102,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");
     }
 }