about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-15 20:12:36 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-15 20:12:36 -0700
commit0192e2031f41b1eabe0c2d764d7710fafe8f4a01 (patch)
tree6b63c352c54b8118d247badbfce0f5d66c053fa9
parent91e30acbd890a10d70d0c08e4f63ecd342b4b00d (diff)
downloadmu-0192e2031f41b1eabe0c2d764d7710fafe8f4a01.tar.gz
.
-rw-r--r--shell/main.mu7
-rw-r--r--shell/sandbox.mu7
2 files changed, 9 insertions, 5 deletions
diff --git a/shell/main.mu b/shell/main.mu
index e0aac0ad..e6df31ee 100644
--- a/shell/main.mu
+++ b/shell/main.mu
@@ -66,19 +66,16 @@ fn load-state data-disk: (addr disk), _sandbox: (addr sandbox), globals: (addr g
 #   ((globals . ((a . (fn ...))
 #                ...))
 #    (sandbox . ...))
-fn store-state data-disk: (addr disk), _sandbox: (addr sandbox), _globals: (addr global-table) {
+fn store-state data-disk: (addr disk), sandbox: (addr sandbox), globals: (addr global-table) {
   compare data-disk, 0/no-disk
   {
     break-if-!=
     return
   }
-  var sandbox/eax: (addr sandbox) <- copy _sandbox
-  var data-ah/eax: (addr handle gap-buffer) <- get sandbox, data
-  var data/eax: (addr gap-buffer) <- lookup *data-ah
   var stream-storage: (stream byte 0x200)
   var stream/edi: (addr stream byte) <- address stream-storage
   write stream, "((sandbox . "
-  append-gap-buffer data, stream
+  write-sandbox stream, sandbox
   write stream, "))"
   store-sector data-disk, 0/lba, stream
 }
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 1a82f52a..69cb511b 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -53,6 +53,13 @@ fn allocate-sandbox-with _out: (addr handle sandbox), s: (addr array byte) {
   initialize-sandbox-with out-addr, s
 }
 
+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
+  append-gap-buffer data, out
+}
+
 ##
 
 fn render-sandbox screen: (addr screen), _self: (addr sandbox), xmin: int, ymin: int, xmax: int, ymax: int, globals: (addr global-table) {