about summary refs log tree commit diff stats
path: root/shell/sandbox.mu
diff options
context:
space:
mode:
Diffstat (limited to 'shell/sandbox.mu')
-rw-r--r--shell/sandbox.mu19
1 files changed, 16 insertions, 3 deletions
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
 }