about summary refs log tree commit diff stats
path: root/shell
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-26 02:06:55 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-26 02:08:09 -0700
commit81c3678515e9fe848daeec129918a7baf929bf96 (patch)
treecfb11b006888ad8712c5cdfdb3d614611ff92d8c /shell
parent6a92f3b5353b758d9b95c612fbce345d73402c0b (diff)
downloadmu-81c3678515e9fe848daeec129918a7baf929bf96.tar.gz
gracefully trace large multi-dimensional arrays
Diffstat (limited to 'shell')
-rw-r--r--shell/print.mu14
1 files changed, 10 insertions, 4 deletions
diff --git a/shell/print.mu b/shell/print.mu
index 4fbba0aa..470ceae3 100644
--- a/shell/print.mu
+++ b/shell/print.mu
@@ -121,8 +121,12 @@ fn print-cell _in: (addr handle cell), out: (addr stream byte), trace: (addr tra
   compare *in-type, 7/array
   {
     break-if-!=
-    # TODO: gracefully handle trace filling up
-    write out, "{array"
+    {
+      var overflow?/eax: boolean <- try-write out, "{array"
+      compare overflow?, 0/false
+      break-if-=
+      return
+    }
     var data-ah/eax: (addr handle array handle cell) <- get in-addr, array-data
     var _data/eax: (addr array handle cell) <- lookup *data-ah
     var data/esi: (addr array handle cell) <- copy _data
@@ -139,13 +143,15 @@ fn print-cell _in: (addr handle cell), out: (addr stream byte), trace: (addr tra
         error trace, "print-cell: no space for array"
         return
       }
-      write out " "
+      var overflow?/eax: boolean <- try-write out " "
+      compare overflow?, 0/false
+      break-if-!=
       var curr-ah/eax: (addr handle cell) <- index data, i
       print-cell curr-ah, out, trace
       i <- increment
       loop
     }
-    write out, "}"
+    var dummy/eax: boolean <- try-write out, "}"
     trace-higher trace
     return
   }