about summary refs log tree commit diff stats
path: root/baremetal/shell/value-stack.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-02-14 13:20:37 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-02-14 13:20:37 -0800
commit1a9d3cb7efa84c0399fc852b93021eff89195d9d (patch)
treec502e0f7380006a880635ea5c298f27c37c8eb10 /baremetal/shell/value-stack.mu
parent90a8d404afcad67dd2ad87ed6241285149d3ca6e (diff)
downloadmu-1a9d3cb7efa84c0399fc852b93021eff89195d9d.tar.gz
7740 - baremetal/shell: eval and render line
Diffstat (limited to 'baremetal/shell/value-stack.mu')
-rw-r--r--baremetal/shell/value-stack.mu27
1 files changed, 27 insertions, 0 deletions
diff --git a/baremetal/shell/value-stack.mu b/baremetal/shell/value-stack.mu
index e58d91d2..a422e9ff 100644
--- a/baremetal/shell/value-stack.mu
+++ b/baremetal/shell/value-stack.mu
@@ -180,3 +180,30 @@ fn dump-stack _self: (addr value-stack) {
     loop
   }
 }
+
+fn render-value-stack screen: (addr screen), _self: (addr value-stack), x: int, y: int -> _/eax: int, _/ecx: int {
+  var self/ecx: (addr value-stack) <- copy _self
+  var data-ah/eax: (addr handle array value) <- get self, data
+  var _data/eax: (addr array value) <- lookup *data-ah
+  var data/edi: (addr array value) <- copy _data
+  var top-addr/eax: (addr int) <- get self, top
+  var curr-idx/ecx: int <- copy *top-addr
+  curr-idx <- decrement
+  var new-x/edx: int <- copy 0
+  {
+    compare curr-idx, 0
+    break-if-<
+    var dest-offset/eax: (offset value) <- compute-offset data, curr-idx
+    var curr/eax: (addr value) <- index data, dest-offset
+    var curr-x/eax: int <- render-value screen, curr, x, y, 1/top-level
+    {
+      compare curr-x, new-x
+      break-if-<=
+      new-x <- copy curr-x
+    }
+    curr-idx <- decrement
+    increment y
+    loop
+  }
+  return new-x, y
+}