about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--shell/global.mu26
-rw-r--r--shell/sandbox.mu19
2 files changed, 29 insertions, 16 deletions
diff --git a/shell/global.mu b/shell/global.mu
index 6e0ff806..860deea6 100644
--- a/shell/global.mu
+++ b/shell/global.mu
@@ -68,37 +68,37 @@ fn load-globals in: (addr handle cell), self: (addr global-table) {
   var remaining-ah/esi: (addr handle cell) <- copy in
   {
     var _remaining/eax: (addr cell) <- lookup *remaining-ah
-    var remaining/ecx: (addr cell) <- copy _remaining
+    var remaining/ebx: (addr cell) <- copy _remaining
     var done?/eax: boolean <- nil? remaining
     compare done?, 0/false
     break-if-!=
 #?     draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "b", 2/fg 0/bg
     var curr-ah/eax: (addr handle cell) <- get remaining, left
-    var curr/eax: (addr cell) <- lookup *curr-ah
+    var _curr/eax: (addr cell) <- lookup *curr-ah
+    var curr/ecx: (addr cell) <- copy _curr
     remaining-ah <- get remaining, right
-    {
-      draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " ", 2/fg 0/bg
-      var name-ah/ecx: (addr handle cell) <- get curr, left
-      var name/eax: (addr cell) <- lookup *name-ah
-      var name-data-ah/eax: (addr handle stream byte) <- get name, text-data
-      var name-data/eax: (addr stream byte) <- lookup *name-data-ah
-      rewind-stream name-data
-      draw-stream-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, name-data, 3/fg, 0/bg
-    }
+    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, " ", 2/fg 0/bg
+    var name-ah/eax: (addr handle cell) <- get curr, left
+    var name/eax: (addr cell) <- lookup *name-ah
+    var name-data-ah/eax: (addr handle stream byte) <- get name, text-data
+    var _name-data/eax: (addr stream byte) <- lookup *name-data-ah
+    var name-data/edx: (addr stream byte) <- copy _name-data
+    rewind-stream name-data
+    draw-stream-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, name-data, 3/fg, 0/bg
     var value-ah/eax: (addr handle cell) <- get curr, right
     var value/eax: (addr cell) <- lookup *value-ah
     var value-data-ah/eax: (addr handle stream byte) <- get value, text-data
     var _value-data/eax: (addr stream byte) <- lookup *value-data-ah
     var value-data/ecx: (addr stream byte) <- copy _value-data
     var value-gap-buffer-storage: (handle gap-buffer)
-    var value-gap-buffer-ah/edx: (addr handle gap-buffer) <- address value-gap-buffer-storage
+    var value-gap-buffer-ah/edi: (addr handle gap-buffer) <- address value-gap-buffer-storage
     allocate value-gap-buffer-ah
     var value-gap-buffer/eax: (addr gap-buffer) <- lookup *value-gap-buffer-ah
     initialize-gap-buffer value-gap-buffer, 0x1000/4KB
 #?     draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "w", 2/fg 0/bg
     load-gap-buffer-from-stream value-gap-buffer, value-data
 #?     draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "x", 2/fg 0/bg
-    read-evaluate-and-move-to-globals value-gap-buffer-ah, self
+    read-evaluate-and-move-to-globals value-gap-buffer-ah, self, name-data
 #?     draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "y", 2/fg 0/bg
     loop
   }
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 87cebfe6..abae14e7 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -666,7 +666,7 @@ fn run _in-ah: (addr handle gap-buffer), out: (addr stream byte), globals: (addr
   mark-lines-dirty trace
 }
 
-fn read-evaluate-and-move-to-globals _in-ah: (addr handle gap-buffer), globals: (addr global-table) {
+fn read-evaluate-and-move-to-globals _in-ah: (addr handle gap-buffer), globals: (addr global-table), definition-name: (addr stream byte) {
   var in-ah/eax: (addr handle gap-buffer) <- copy _in-ah
   var in/eax: (addr gap-buffer) <- lookup *in-ah
   var read-result-h: (handle cell)
@@ -675,7 +675,6 @@ fn read-evaluate-and-move-to-globals _in-ah: (addr handle gap-buffer), globals:
   var trace/edx: (addr trace) <- address trace-storage
   initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
   read-cell in, read-result-ah, trace
-  clear-trace trace
   macroexpand read-result-ah, globals, trace
   var nil-storage: (handle cell)
   var nil-ah/eax: (addr handle cell) <- address nil-storage
@@ -683,8 +682,22 @@ fn read-evaluate-and-move-to-globals _in-ah: (addr handle gap-buffer), globals:
   var eval-result-storage: (handle cell)
   var eval-result/edi: (addr handle cell) <- address eval-result-storage
   debug-print "^", 4/fg, 0/bg
-  clear-trace trace
   evaluate read-result-ah, eval-result, *nil-ah, globals, trace, 0/no-screen-cell, 0/no-keyboard-cell, 1/call-number
+  {
+    var error?/eax: boolean <- has-errors? trace
+    compare error?, 0/false
+    break-if-=
+    set-cursor-position 0/screen, 0x40/x, 0x18/y
+    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "error when loading definition for ", 4/fg 0/bg
+    rewind-stream definition-name
+    draw-stream-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, definition-name, 3/fg 0/bg
+    set-cursor-position 0/screen, 0x40/x, 0x19/y
+    draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "see trace in grey at top-left", 7/fg 0/bg
+    dump-trace trace  # will print from 0, 0
+    {
+      loop
+    }
+  }
   debug-print "$", 4/fg, 0/bg
   move-gap-buffer-to-global globals, read-result-ah, _in-ah
 }