about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-15 20:56:52 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-15 20:56:52 -0700
commit0f760bd60c3861766b2e50009bf2b958f5f65f8b (patch)
tree260ba2978225a919399961c835b7abae7b5f86e8
parentb2e0ce69ef7bda06971a29bb8a24ff915c53ffd1 (diff)
downloadmu-0f760bd60c3861766b2e50009bf2b958f5f65f8b.tar.gz
.
-rw-r--r--shell/global.mu2
-rw-r--r--shell/main.mu12
-rw-r--r--shell/sandbox.mu8
3 files changed, 17 insertions, 5 deletions
diff --git a/shell/global.mu b/shell/global.mu
index c8e849e2..3410654d 100644
--- a/shell/global.mu
+++ b/shell/global.mu
@@ -45,7 +45,7 @@ fn initialize-globals _self: (addr global-table) {
 }
 
 fn write-globals out: (addr stream byte), _self: (addr global-table) {
-  write out, "()\n"
+  write out, "  (globals . ())\n"
 }
 
 fn render-globals screen: (addr screen), _self: (addr global-table), xmin: int, ymin: int, xmax: int, ymax: int {
diff --git a/shell/main.mu b/shell/main.mu
index 5d5dc987..a13e6b83 100644
--- a/shell/main.mu
+++ b/shell/main.mu
@@ -56,6 +56,12 @@ fn load-state data-disk: (addr disk), _sandbox: (addr sandbox), globals: (addr g
   var sandbox-cell-storage: (handle cell)
   var sandbox-cell-ah/edx: (addr handle cell) <- address sandbox-cell-storage
   lookup-symbol sandbox-literal, sandbox-cell-ah, *initial-root, 0/no-globals, 0/no-trace, 0/no-screen, 0/no-keyboard
+  var sandbox-cell/eax: (addr cell) <- lookup *sandbox-cell-ah
+  compare sandbox-cell, 0
+  {
+    break-if-!=
+    return
+  }
   # print: cell -> stream
   print-cell sandbox-cell-ah, s, 0/no-trace
   # stream -> gap-buffer
@@ -74,11 +80,9 @@ fn store-state data-disk: (addr disk), sandbox: (addr sandbox), globals: (addr g
   }
   var stream-storage: (stream byte 0x200)
   var stream/edi: (addr stream byte) <- address stream-storage
-  write stream, "((globals . "
+  write stream, "(\n"
   write-globals stream, globals
-  write stream, " )\n"
-  write stream, " (sandbox . "
   write-sandbox stream, sandbox
-  write stream, "))"
+  write stream, ")\n"
   store-sector data-disk, 0/lba, stream
 }
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 69cb511b..a2fe3758 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -57,7 +57,15 @@ fn write-sandbox out: (addr stream byte), _self: (addr sandbox) {
   var self/eax: (addr sandbox) <- copy _self
   var data-ah/eax: (addr handle gap-buffer) <- get self, data
   var data/eax: (addr gap-buffer) <- lookup *data-ah
+  {
+    var len/eax: int <- gap-buffer-length data
+    compare len, 0
+    break-if-!=
+    return
+  }
+  write out, "  (sandbox . "
   append-gap-buffer data, out
+  write out, ")\n"
 }
 
 ##