From 81c3678515e9fe848daeec129918a7baf929bf96 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 26 Jul 2021 02:06:55 -0700 Subject: gracefully trace large multi-dimensional arrays --- shell/print.mu | 14 ++++++++++---- 1 file 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 } -- cgit 1.4.1-2-gfad0