about summary refs log tree commit diff stats
path: root/shell
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-07-19 19:58:06 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-07-19 19:58:10 -0700
commit8be28fdd4630e8457cfcebe19dac2e3aa68712d3 (patch)
tree79742ebcb0a7c67a33e775f90668439bdb67a321 /shell
parent7204135203524dc7bcb7df6610e0ac45872f46fd (diff)
downloadmu-8be28fdd4630e8457cfcebe19dac2e3aa68712d3.tar.gz
error message when trying to jump to primitive
Diffstat (limited to 'shell')
-rw-r--r--shell/environment.mu15
1 files changed, 15 insertions, 0 deletions
diff --git a/shell/environment.mu b/shell/environment.mu
index 06c667fd..51256d02 100644
--- a/shell/environment.mu
+++ b/shell/environment.mu
@@ -277,6 +277,21 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
         copy-array-object "no such global", go-modal-error-ah
         return
       }
+      # if global is a primitive, set error and return
+      {
+        var global-data-ah/eax: (addr handle array global) <- get globals, data
+        var global-data/eax: (addr array global) <- lookup *global-data-ah
+        var curr-offset/ebx: (offset global) <- compute-offset global-data, curr-index
+        var curr/ebx: (addr global) <- index global-data, curr-offset
+        var curr-value-ah/eax: (addr handle cell) <- get curr, value
+        var curr-value/eax: (addr cell) <- lookup *curr-value-ah
+        var curr-type/eax: (addr int) <- get curr-value, type
+        compare *curr-type, 4/primitive
+        break-if-!=
+        var go-modal-error-ah/eax: (addr handle array byte) <- get self, go-modal-error
+        copy-array-object "sorry, primitives can't be edited yet", go-modal-error-ah
+        return
+      }
       # otherwise clear modal state
       clear-gap-buffer partial-global-name
       var go-modal-error-ah/eax: (addr handle array byte) <- get self, go-modal-error