error message when trying to jump to primitive

This commit is contained in:
Kartik K. Agaram 2021-07-19 19:58:06 -07:00
parent 7204135203
commit 8be28fdd46
1 changed files with 15 additions and 0 deletions

View File

@ -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