about summary refs log tree commit diff stats
path: root/baremetal
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-02-21 21:25:38 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-02-21 21:26:08 -0800
commit8b8d0fc77130c6f39aae42319aee1f449fd4db70 (patch)
treebdf3516884e159fcd33874d837e53816cebd25fd /baremetal
parent7e9e65eece359d6bb28d202eec035cf7acc5118a (diff)
downloadmu-8b8d0fc77130c6f39aae42319aee1f449fd4db70.tar.gz
7772
Diffstat (limited to 'baremetal')
-rw-r--r--baremetal/shell/eval.mu19
-rw-r--r--baremetal/shell/main.mu20
-rw-r--r--baremetal/shell/sandbox.mu10
3 files changed, 29 insertions, 20 deletions
diff --git a/baremetal/shell/eval.mu b/baremetal/shell/eval.mu
index 8af64a95..e69de29b 100644
--- a/baremetal/shell/eval.mu
+++ b/baremetal/shell/eval.mu
@@ -1,19 +0,0 @@
-type interpreter {
-  # tokenize
-  # insert parens
-  # transform infix
-  # token tree
-  # syntax tree
-}
-
-fn evaluate _self: (addr interpreter), in: (addr stream byte), out: (addr stream byte) {
-  clear-stream out
-  {
-    var done?/eax: boolean <- stream-empty? in
-    compare done?, 0/false
-    break-if-!=
-    var g/eax: grapheme <- read-grapheme in
-    write-grapheme out, g
-    loop
-  }
-}
diff --git a/baremetal/shell/main.mu b/baremetal/shell/main.mu
index f3f6240c..e54515ed 100644
--- a/baremetal/shell/main.mu
+++ b/baremetal/shell/main.mu
@@ -20,3 +20,23 @@ fn main {
     loop
   }
 }
+
+type interpreter {
+  # tokenize
+  # insert parens
+  # transform infix
+  # token tree
+  # syntax tree
+}
+
+fn run _self: (addr interpreter), in: (addr stream byte), out: (addr stream byte) {
+  clear-stream out
+  {
+    var done?/eax: boolean <- stream-empty? in
+    compare done?, 0/false
+    break-if-!=
+    var g/eax: grapheme <- read-grapheme in
+    write-grapheme out, g
+    loop
+  }
+}
diff --git a/baremetal/shell/sandbox.mu b/baremetal/shell/sandbox.mu
index d1a24c47..b002ce0a 100644
--- a/baremetal/shell/sandbox.mu
+++ b/baremetal/shell/sandbox.mu
@@ -69,6 +69,14 @@ fn edit-sandbox _self: (addr sandbox), key: byte, interpreter: (addr interpreter
     return
   }
   {
+    compare g, 0x12/ctrl-r
+    break-if-!=
+    # ctrl-r: run function outside sandbox
+    # required: fn (addr screen), (addr keyboard)
+    # Mu will pass in the real screen and keyboard.
+    return
+  }
+  {
     compare g, 0x13/ctrl-s
     break-if-!=
     # ctrl-s: run sandbox(es)
@@ -79,7 +87,7 @@ fn edit-sandbox _self: (addr sandbox), key: byte, interpreter: (addr interpreter
     emit-gap-buffer data, buffer
     var value-ah/eax: (addr handle stream byte) <- get self, value
     var value/eax: (addr stream byte) <- lookup *value-ah
-    evaluate interpreter, buffer, value
+    run interpreter, buffer, value
     return
   }
   add-grapheme-to-sandbox self, g