about summary refs log tree commit diff stats
path: root/shell/print.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-10 23:05:16 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-10 23:05:16 -0700
commitb0096cd6a694e1ccad19d6b3849bd032af6a4fe9 (patch)
treefc980956ae69ec47ce2f9c25c2047b811001cb77 /shell/print.mu
parentf38c2a1502648b0be16fc2e984420886cf64cdee (diff)
downloadmu-b0096cd6a694e1ccad19d6b3849bd032af6a4fe9.tar.gz
shell: streams that you can append graphemes to
Diffstat (limited to 'shell/print.mu')
-rw-r--r--shell/print.mu26
1 files changed, 26 insertions, 0 deletions
diff --git a/shell/print.mu b/shell/print.mu
index 307b9ffd..ce65b4df 100644
--- a/shell/print.mu
+++ b/shell/print.mu
@@ -40,6 +40,13 @@ fn print-cell _in: (addr handle cell), out: (addr stream byte), trace: (addr tra
     trace-higher trace
     return
   }
+  compare *in-type, 3/stream
+  {
+    break-if-!=
+    print-stream in-addr, out, trace
+    trace-higher trace
+    return
+  }
   compare *in-type, 4/primitive
   {
     break-if-!=
@@ -88,6 +95,25 @@ fn print-symbol _in: (addr cell), out: (addr stream byte), trace: (addr trace) {
   trace trace, "print", stream
 }
 
+fn print-stream _in: (addr cell), out: (addr stream byte), trace: (addr trace) {
+  trace-text trace, "print", "stream"
+  var in/esi: (addr cell) <- copy _in
+  var data-ah/eax: (addr handle stream byte) <- get in, text-data
+  var _data/eax: (addr stream byte) <- lookup *data-ah
+  var data/esi: (addr stream byte) <- copy _data
+  rewind-stream data
+  write out, "["
+  write-stream out, data
+  write out, "]"
+  # trace
+  rewind-stream data
+  var stream-storage: (stream byte 0x40)
+  var stream/ecx: (addr stream byte) <- address stream-storage
+  write stream, "=> stream "
+  write-stream stream, data
+  trace trace, "print", stream
+}
+
 fn print-number _in: (addr cell), out: (addr stream byte), trace: (addr trace) {
   var in/esi: (addr cell) <- copy _in
   var val/eax: (addr float) <- get in, number-data