about summary refs log tree commit diff stats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/global.mu46
1 files changed, 44 insertions, 2 deletions
diff --git a/shell/global.mu b/shell/global.mu
index cf914ef1..107d85e7 100644
--- a/shell/global.mu
+++ b/shell/global.mu
@@ -25,14 +25,38 @@ fn initialize-globals _self: (addr global-table) {
 fn render-globals screen: (addr screen), _self: (addr global-table), xmin: int, ymin: int, xmax: int, ymax: int {
   clear-rect screen, xmin, ymin, xmax, ymax, 0x12/bg=almost-black
   var self/esi: (addr global-table) <- copy _self
+  # render primitives
+  var bottom-line/ecx: int <- copy ymax
+  bottom-line <- decrement
+  var data-ah/eax: (addr handle array global) <- get self, data
+  var data/eax: (addr array global) <- lookup *data-ah
+  var curr-index/edx: int <- copy 1
+  var x/edi: int <- copy xmin
+  {
+    var curr-offset/ebx: (offset global) <- compute-offset data, curr-index
+    var curr/ebx: (addr global) <- index data, curr-offset
+    var continue?/eax: boolean <- primitive-global? curr
+    compare continue?, 0/false
+    break-if-=
+    var curr-name-ah/eax: (addr handle array byte) <- get curr, name
+    var _curr-name/eax: (addr array byte) <- lookup *curr-name-ah
+    var curr-name/ebx: (addr array byte) <- copy _curr-name
+    var tmpx/eax: int <- copy x
+    tmpx <- draw-text-rightward screen, curr-name, tmpx, xmax, bottom-line, 0x2a/fg=orange, 0x12/bg=almost-black
+    tmpx <- draw-text-rightward screen, " ", tmpx, xmax, bottom-line, 7/fg=grey, 0x12/bg=almost-black
+    x <- copy tmpx
+    curr-index <- increment
+    loop
+  }
+  var lowest-index/edi: int <- copy curr-index
   var y/ecx: int <- copy ymin
   var data-ah/eax: (addr handle array global) <- get self, data
   var data/eax: (addr array global) <- lookup *data-ah
   var final-index/edx: (addr int) <- get self, final-index
   var curr-index/edx: int <- copy *final-index
   {
-    compare curr-index, 0
-    break-if-<=
+    compare curr-index, lowest-index
+    break-if-<
     compare y, ymax
     break-if->=
     {
@@ -56,6 +80,24 @@ fn render-globals screen: (addr screen), _self: (addr global-table), xmin: int,
   }
 }
 
+fn primitive-global? _x: (addr global) -> _/eax: boolean {
+  var x/eax: (addr global) <- copy _x
+  var value-ah/eax: (addr handle cell) <- get x, value
+  var value/eax: (addr cell) <- lookup *value-ah
+  compare value, 0/null
+  {
+    break-if-!=
+    return 0/false
+  }
+  var value-type/eax: (addr int) <- get value, type
+  compare *value-type, 4/primitive
+  {
+    break-if-=
+    return 0/false
+  }
+  return 1/true
+}
+
 fn append-primitive _self: (addr global-table), name: (addr array byte) {
   var self/esi: (addr global-table) <- copy _self
   var final-index-addr/ecx: (addr int) <- get self, final-index