about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-05 21:35:46 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-05 21:35:46 -0700
commita9e56c46c6e2d9a6c89e0b4ab16bd5c2ae9cb3da (patch)
tree7320ef357272e25e4313f9da13cc539dd434c384 /apps
parent88e23b97dfbe275296f3722b1ce589aee3fc0af2 (diff)
downloadmu-a9e56c46c6e2d9a6c89e0b4ab16bd5c2ae9cb3da.tar.gz
6966
Diffstat (limited to 'apps')
-rw-r--r--apps/tile/data.mu15
-rw-r--r--apps/tile/environment.mu35
2 files changed, 15 insertions, 35 deletions
diff --git a/apps/tile/data.mu b/apps/tile/data.mu
index 4e82bb65..52f2a8c4 100644
--- a/apps/tile/data.mu
+++ b/apps/tile/data.mu
@@ -1,8 +1,3 @@
-type program {
-  functions: (handle function)
-  sandboxes: (handle sandbox)
-}
-
 type sandbox {
   setup: (handle line)
   data: (handle line)
@@ -59,16 +54,6 @@ type result {
   error: (handle array byte)  # single error message for now
 }
 
-fn initialize-program _program: (addr program) {
-  var program/esi: (addr program) <- copy _program
-  var functions/eax: (addr handle function) <- get program, functions
-  create-primitive-functions functions
-  var sandbox-ah/eax: (addr handle sandbox) <- get program, sandboxes
-  allocate sandbox-ah
-  var sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
-  initialize-sandbox sandbox
-}
-
 fn initialize-sandbox _sandbox: (addr sandbox) {
   var sandbox/esi: (addr sandbox) <- copy _sandbox
   var line-ah/eax: (addr handle line) <- get sandbox, data
diff --git a/apps/tile/environment.mu b/apps/tile/environment.mu
index 132e5151..2e7ae970 100644
--- a/apps/tile/environment.mu
+++ b/apps/tile/environment.mu
@@ -1,6 +1,7 @@
 type environment {
   screen: (handle screen)
-  program: (handle program)
+  functions: (handle function)
+  sandboxes: (handle sandbox)
   nrows: int
   ncols: int
   code-separator-col: int
@@ -8,10 +9,14 @@ type environment {
 
 fn initialize-environment _env: (addr environment) {
   var env/esi: (addr environment) <- copy _env
-  var program-ah/eax: (addr handle program) <- get env, program
-  allocate program-ah
-  var program/eax: (addr program) <- lookup *program-ah
-  initialize-program program
+  # initialize some predefined function definitions
+  var functions/eax: (addr handle function) <- get env, functions
+  create-primitive-functions functions
+  # initialize first sandbox
+  var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
+  allocate sandbox-ah
+  var sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
+  initialize-sandbox sandbox
   # initialize screen
   var screen-ah/eax: (addr handle screen) <- get env, screen
   var _screen/eax: (addr screen) <- lookup *screen-ah
@@ -53,9 +58,7 @@ fn initialize-environment-with-fake-screen _self: (addr environment), nrows: int
 fn process _self: (addr environment), key: grapheme {
 $process:body: {
     var self/esi: (addr environment) <- copy _self
-    var program-ah/eax: (addr handle program) <- get self, program
-    var program/eax: (addr program) <- lookup *program-ah
-    var sandbox-ah/eax: (addr handle sandbox) <- get program, sandboxes
+    var sandbox-ah/eax: (addr handle sandbox) <- get self, sandboxes
     var sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
     var cursor-word-ah/edi: (addr handle word) <- get sandbox, cursor-word
     var _cursor-word/eax: (addr word) <- lookup *cursor-word-ah
@@ -161,14 +164,10 @@ $process:body: {
 
 fn evaluate-environment _env: (addr environment), stack: (addr value-stack) {
   var env/esi: (addr environment) <- copy _env
-  # program
-  var program-ah/eax: (addr handle program) <- get env, program
-  var _program/eax: (addr program) <- lookup *program-ah
-  var program/esi: (addr program) <- copy _program
   # functions
-  var functions/edx: (addr handle function) <- get program, functions
+  var functions/edx: (addr handle function) <- get env, functions
   # line
-  var sandbox-ah/esi: (addr handle sandbox) <- get program, sandboxes
+  var sandbox-ah/esi: (addr handle sandbox) <- get env, sandboxes
   var sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
   var line-ah/eax: (addr handle line) <- get sandbox, data
   var _line/eax: (addr line) <- lookup *line-ah
@@ -187,14 +186,10 @@ fn render _env: (addr environment) {
   var _repl-col/eax: (addr int) <- get env, code-separator-col
   var repl-col/ecx: int <- copy *_repl-col
   repl-col <- add 2  # repl-margin-left
-  # program
-  var program-ah/eax: (addr handle program) <- get env, program
-  var _program/eax: (addr program) <- lookup *program-ah
-  var program/esi: (addr program) <- copy _program
   # functions
-  var functions/edx: (addr handle function) <- get program, functions
+  var functions/edx: (addr handle function) <- get env, functions
   # sandbox
-  var sandbox-ah/eax: (addr handle sandbox) <- get program, sandboxes
+  var sandbox-ah/eax: (addr handle sandbox) <- get env, sandboxes
   var sandbox/eax: (addr sandbox) <- lookup *sandbox-ah
   render-sandbox screen, functions, 0, sandbox, 3, repl-col
 }