eliminate some implicit writes to real screen

This commit is contained in:
Kartik K. Agaram 2021-06-12 16:24:23 -07:00
parent 70919b45f0
commit 286819685e
7 changed files with 120 additions and 120 deletions

View File

@ -28,7 +28,7 @@ fn test-environment {
# type some code into sandbox
type-in env, screen, "(+ 3 4)" # we don't have any global definitions here, so no macros
# run code in sandbox
edit-environment env, 0x13/ctrl-s, 0/no-disk
edit-environment env, 0x13/ctrl-s, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# | global definitions | sandbox
# top row blank for now
@ -62,7 +62,7 @@ fn test-definition-in-environment {
initialize-screen screen, 0x80/width=72, 0x10/height, 0/no-pixel-graphics
# define a global on the right (sandbox) side
type-in env, screen, "(define f 42)"
edit-environment env, 0x13/ctrl-s, 0/no-disk
edit-environment env, 0x13/ctrl-s, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# | global definitions | sandbox
check-screen-row screen, 0/y, " ", "F - test-definition-in-environment/0"
@ -83,7 +83,7 @@ fn test-definition-in-environment {
# helper for testing
fn type-in self: (addr environment), screen: (addr screen), keys: (addr array byte) {
# clear the buffer
edit-environment self, 0x15/ctrl-u, 0/no-disk
edit-environment self, 0x15/ctrl-u, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, self
# type in all the keys
var input-stream-storage: (stream byte 0x40/capacity)
@ -94,7 +94,7 @@ fn type-in self: (addr environment), screen: (addr screen), keys: (addr array by
compare done?, 0/false
break-if-!=
var key/eax: grapheme <- read-grapheme input-stream
edit-environment self, key, 0/no-disk
edit-environment self, key, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, self
loop
}
@ -145,7 +145,7 @@ fn render-environment screen: (addr screen), _self: (addr environment) {
render-sandbox-menu screen, sandbox
}
fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr disk) {
fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr disk), outer-screen: (addr screen), outer-keyboard: (addr keyboard) {
var self/esi: (addr environment) <- copy _self
var globals/edi: (addr global-table) <- get self, globals
var sandbox/ecx: (addr sandbox) <- get self, sandbox
@ -189,7 +189,7 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
var trace-storage: trace
var trace/ebx: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp, out-ah, nil, globals, trace, 0/no-fake-screen, 0/no-fake-keyboard, 0/definitions-created, 0/call-number
evaluate tmp, out-ah, nil, globals, trace, 0/no-fake-screen, 0/no-fake-keyboard, 0/definitions-created, 0/no-outer-screen, 0/no-outer-keyboard, 0/call-number
# wait for a keypress
{
var tmp/eax: byte <- read-key 0/keyboard
@ -216,7 +216,7 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
edit-globals globals, key
}
# update sandbox whether the cursor is in globals or sandbox
edit-sandbox sandbox, key, globals, data-disk
edit-sandbox sandbox, key, globals, data-disk, outer-screen, outer-keyboard
}
return
}
@ -366,10 +366,10 @@ fn edit-environment _self: (addr environment), key: grapheme, data-disk: (addr d
edit-globals globals, key
return
}
edit-sandbox sandbox, key, globals, data-disk
edit-sandbox sandbox, key, globals, data-disk, outer-screen, outer-keyboard
}
fn read-and-evaluate-and-save-gap-buffer-to-globals _in-ah: (addr handle gap-buffer), result-ah: (addr handle cell), globals: (addr global-table), definitions-created: (addr stream int), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell) {
fn read-and-evaluate-and-save-gap-buffer-to-globals _in-ah: (addr handle gap-buffer), result-ah: (addr handle cell), globals: (addr global-table), definitions-created: (addr stream int), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), outer-screen: (addr screen), outer-keyboard: (addr keyboard) {
var in-ah/eax: (addr handle gap-buffer) <- copy _in-ah
var in/eax: (addr gap-buffer) <- lookup *in-ah
var read-result-h: (handle cell)
@ -394,7 +394,7 @@ fn read-and-evaluate-and-save-gap-buffer-to-globals _in-ah: (addr handle gap-buf
#? set-cursor-position 0/screen, 0 0
#? turn-on-debug-print
debug-print "^", 4/fg, 0/bg
evaluate read-result-ah, result-ah, *nil-ah, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, 1/call-number
evaluate read-result-ah, result-ah, *nil-ah, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, 1/call-number
debug-print "$", 4/fg, 0/bg
var error?/eax: boolean <- has-errors? trace
{
@ -419,7 +419,7 @@ fn test-go-modal {
var screen/edi: (addr screen) <- address screen-on-stack
initialize-screen screen, 0x80/width=72, 0x10/height, 0/no-pixel-graphics
# hit ctrl-g
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
#
check-background-color-in-screen-row screen, 0xf/bg=modal, 0/y, " ", "F - test-go-modal/0"
@ -454,10 +454,10 @@ fn test-leave-go-modal {
var screen/edi: (addr screen) <- address screen-on-stack
initialize-screen screen, 0x80/width=72, 0x10/height, 0/no-pixel-graphics
# hit ctrl-g
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# cancel
edit-environment env, 0x1b/escape, 0/no-disk
edit-environment env, 0x1b/escape, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# no modal
check-background-color-in-screen-row screen, 0xf/bg=modal, 0/y, " ", "F - test-leave-go-modal/0"
@ -488,15 +488,15 @@ fn test-jump-to-global {
initialize-screen screen, 0x80/width=72, 0x10/height, 0/no-pixel-graphics
# define a global
type-in env, screen, "(define f 42)"
edit-environment env, 0x13/ctrl-s, 0/no-disk
edit-environment env, 0x13/ctrl-s, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# hit ctrl-g
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# type global name
type-in env, screen, "f"
# submit
edit-environment env, 0xa/newline, 0/no-disk
edit-environment env, 0xa/newline, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# | global definitions | sandbox
# cursor now in global definition
@ -532,7 +532,7 @@ fn test-go-modal-prepopulates-word-at-cursor {
# type a word at the cursor
type-in env, screen, "fn1"
# hit ctrl-g
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# modal prepopulates word at cursor
check-background-color-in-screen-row screen, 0xf/bg=modal, 0/y, " ", "F - test-go-modal-prepopulates-word-at-cursor/0"
@ -557,13 +557,13 @@ fn test-go-modal-prepopulates-word-at-cursor {
check-background-color-in-screen-row screen, 0xf/bg=modal, 0xe/y, " ", "F - test-go-modal-prepopulates-word-at-cursor/14"
check-background-color-in-screen-row screen, 0xf/bg=modal, 0xf/y, " ", "F - test-go-modal-prepopulates-word-at-cursor/15"
# cancel
edit-environment env, 0x1b/escape, 0/no-disk
edit-environment env, 0x1b/escape, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# type one more space
edit-environment env, 0x20/space, 0/no-disk
edit-environment env, 0x20/space, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# hit ctrl-g again
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# no word prepopulated since cursor is not on the word
check-background-color-in-screen-row screen, 0xf/bg=modal, 0/y, " ", "F - test-go-modal-prepopulates-word-at-cursor/test2-0"
@ -588,15 +588,15 @@ fn test-go-modal-prepopulates-word-at-cursor {
check-background-color-in-screen-row screen, 0xf/bg=modal, 0xe/y, " ", "F - test-go-modal-prepopulates-word-at-cursor/test2-14"
check-background-color-in-screen-row screen, 0xf/bg=modal, 0xf/y, " ", "F - test-go-modal-prepopulates-word-at-cursor/test2-15"
# cancel
edit-environment env, 0x1b/escape, 0/no-disk
edit-environment env, 0x1b/escape, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# move cursor to the left until it's on the word again
edit-environment env, 0x80/left-arrow, 0/no-disk
edit-environment env, 0x80/left-arrow, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
edit-environment env, 0x80/left-arrow, 0/no-disk
edit-environment env, 0x80/left-arrow, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# hit ctrl-g again
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# word prepopulated like before
check-background-color-in-screen-row screen, 0xf/bg=modal, 0/y, " ", "F - test-go-modal-prepopulates-word-at-cursor/test3-0"
@ -633,10 +633,10 @@ fn test-jump-to-nonexistent-global {
# type in any (nonexistent) global name
type-in env, screen, "f"
# hit ctrl-g
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# submit
edit-environment env, 0xa/newline, 0/no-disk
edit-environment env, 0xa/newline, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# modal now shows an error
# | global definitions | sandbox
@ -663,10 +663,10 @@ fn test-jump-to-nonexistent-global {
check-screen-row screen, 0xf/y, " ^r run main enter go ^m create esc cancel ^a << ^b <word ^f word> ^e >> ", "F - test-jump-to-nonexistent-global/15-text"
check-background-color-in-screen-row screen, 0xf/bg=modal, 0xf/y, " ", "F - test-jump-to-nonexistent-global/15"
# cancel
edit-environment env, 0x1b/escape, 0/no-disk
edit-environment env, 0x1b/escape, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# hit ctrl-g again
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# word prepopulated like before, but no error
check-background-color-in-screen-row screen, 0xf/bg=modal, 0/y, " ", "F - test-jump-to-nonexistent-global/test2-0"
@ -702,12 +702,12 @@ fn test-create-global {
var screen/edi: (addr screen) <- address screen-on-stack
initialize-screen screen, 0x80/width=72, 0x10/height, 0/no-pixel-graphics
# hit ctrl-g
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# type global name
type-in env, screen, "fn1"
# create
edit-environment env, 0xd/ctrl-m, 0/no-disk
edit-environment env, 0xd/ctrl-m, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# | global definitions | sandbox
# cursor now on global side
@ -741,15 +741,15 @@ fn test-create-nonexistent-global {
initialize-screen screen, 0x80/width=72, 0x10/height, 0/no-pixel-graphics
# define a global
type-in env, screen, "(define f 42)"
edit-environment env, 0x13/ctrl-s, 0/no-disk
edit-environment env, 0x13/ctrl-s, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# type in its name
type-in env, screen, "f"
# hit ctrl-g
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# submit
edit-environment env, 0xd/ctrl-m, 0/no-disk
edit-environment env, 0xd/ctrl-m, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# modal now shows an error
# | global definitions | sandbox
@ -776,10 +776,10 @@ fn test-create-nonexistent-global {
check-screen-row screen, 0xf/y, " ^r run main enter go ^m create esc cancel ^a << ^b <word ^f word> ^e >> ", "F - test-create-nonexistent-global/15-text"
check-background-color-in-screen-row screen, 0xf/bg=modal, 0xf/y, " ", "F - test-create-nonexistent-global/15"
# cancel
edit-environment env, 0x1b/escape, 0/no-disk
edit-environment env, 0x1b/escape, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# hit ctrl-g again
edit-environment env, 7/ctrl-g, 0/no-disk
edit-environment env, 7/ctrl-g, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-environment screen, env
# word prepopulated like before, but no error
check-background-color-in-screen-row screen, 0xf/bg=modal, 0/y, " ", "F - test-create-nonexistent-global/test2-0"

View File

@ -8,7 +8,7 @@
# stops if a keypress is encountered
# Inner screen is what Lisp programs modify. Outer screen is shows the program
# and its inner screen to the environment.
fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), call-number: int {
fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), outer-screen: (addr screen), outer-keyboard: (addr keyboard), call-number: int {
# stack overflow? # disable when enabling Really-debug-print
check-stack
{
@ -34,8 +34,8 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var screen-obj/eax: (addr screen) <- lookup *screen-obj-ah
compare screen-obj, 0
break-if-=
var y/ecx: int <- render-screen 0/screen, screen-obj, 0x58/xmin, 2/ymin
var key/eax: byte <- read-key 0/keyboard
var y/ecx: int <- render-screen outer-screen, screen-obj, 0x58/xmin, 2/ymin
var key/eax: byte <- read-key outer-keyboard
compare key, 0
break-if-=
error trace, "key pressed; interrupting..."
@ -211,7 +211,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
#
trace-text trace, "eval", "backquote"
debug-print "`(", 7/fg, 0/bg
evaluate-backquote rest-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate-backquote rest-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print ")", 7/fg, 0/bg
trace-higher trace
return
@ -245,7 +245,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var second-arg-ah/edx: (addr handle cell) <- get rest, left
debug-print "P", 4/fg, 0/bg
increment call-number
evaluate second-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate second-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "Q", 4/fg, 0/bg
# errors? skip
{
@ -305,7 +305,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var second-arg-ah/edx: (addr handle cell) <- get rest, left
debug-print "P", 4/fg, 0/bg
increment call-number
evaluate second-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate second-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "Q", 4/fg, 0/bg
# errors? skip
{
@ -339,7 +339,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var first-arg-ah/ecx: (addr handle cell) <- get rest, left
debug-print "R2", 4/fg, 0/bg
increment call-number
evaluate first-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate first-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "S2", 4/fg, 0/bg
# errors? skip
{
@ -365,7 +365,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var second-ah/eax: (addr handle cell) <- get rest, left
debug-print "T2", 4/fg, 0/bg
increment call-number
evaluate second-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate second-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "U2", 4/fg, 0/bg
trace-higher trace
return
@ -386,7 +386,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var first-arg-ah/ecx: (addr handle cell) <- get rest, left
debug-print "R2", 4/fg, 0/bg
increment call-number
evaluate first-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate first-arg-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "S2", 4/fg, 0/bg
# errors? skip
{
@ -412,7 +412,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var second-ah/eax: (addr handle cell) <- get rest, left
debug-print "T2", 4/fg, 0/bg
increment call-number
evaluate second-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate second-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "U2", 4/fg, 0/bg
# errors? skip
{
@ -444,7 +444,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var guard-ah/esi: (addr handle cell) <- address guard-h
debug-print "R", 4/fg, 0/bg
increment call-number
evaluate first-arg-ah, guard-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate first-arg-ah, guard-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "S", 4/fg, 0/bg
# errors? skip
{
@ -470,7 +470,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
}
debug-print "T", 4/fg, 0/bg
increment call-number
evaluate branch-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate branch-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "U", 4/fg, 0/bg
trace-higher trace
return
@ -506,7 +506,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
trace-text trace, "eval", "loop termination check"
debug-print "V", 4/fg, 0/bg
increment call-number
evaluate first-arg-ah, guard-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate first-arg-ah, guard-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "W", 4/fg, 0/bg
# errors? skip
{
@ -520,7 +520,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var done?/eax: boolean <- nil? guard-a
compare done?, 0/false
break-if-!=
evaluate-exprs rest-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate-exprs rest-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
# errors? skip
{
var error?/eax: boolean <- has-errors? trace
@ -566,7 +566,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var left-ah/esi: (addr handle cell) <- get curr, left
debug-print "A", 4/fg, 0/bg
increment call-number
evaluate left-ah, left-out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate left-ah, left-out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "B", 4/fg, 0/bg
# errors? skip
{
@ -589,7 +589,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
var function-ah/ecx: (addr handle cell) <- get evaluated-list, left
var args-ah/edx: (addr handle cell) <- get evaluated-list, right
debug-print "C", 4/fg, 0/bg
apply function-ah, args-ah, _out-ah, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
apply function-ah, args-ah, _out-ah, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "Y", 4/fg, 0/bg
trace-higher trace
# trace "=> " _out-ah {{{
@ -610,7 +610,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
debug-print "Z", 4/fg, 0/bg
}
fn apply _f-ah: (addr handle cell), args-ah: (addr handle cell), out: (addr handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), call-number: int {
fn apply _f-ah: (addr handle cell), args-ah: (addr handle cell), out: (addr handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), outer-screen: (addr screen), outer-keyboard: (addr keyboard), call-number: int {
var f-ah/eax: (addr handle cell) <- copy _f-ah
var _f/eax: (addr cell) <- lookup *f-ah
var f/esi: (addr cell) <- copy _f
@ -660,7 +660,7 @@ fn apply _f-ah: (addr handle cell), args-ah: (addr handle cell), out: (addr hand
var params-ah/ecx: (addr handle cell) <- get rest, left
var body-ah/eax: (addr handle cell) <- get rest, right
debug-print "D", 7/fg, 0/bg
apply-function params-ah, args-ah, body-ah, out, *callee-env-ah, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
apply-function params-ah, args-ah, body-ah, out, *callee-env-ah, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "Y", 7/fg, 0/bg
trace-higher trace
return
@ -668,7 +668,7 @@ fn apply _f-ah: (addr handle cell), args-ah: (addr handle cell), out: (addr hand
error trace, "unknown function"
}
fn apply-function params-ah: (addr handle cell), args-ah: (addr handle cell), body-ah: (addr handle cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), call-number: int {
fn apply-function params-ah: (addr handle cell), args-ah: (addr handle cell), body-ah: (addr handle cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), outer-screen: (addr screen), outer-keyboard: (addr keyboard), call-number: int {
# push bindings for params to env
var new-env-h: (handle cell)
var new-env-ah/esi: (addr handle cell) <- address new-env-h
@ -681,10 +681,10 @@ fn apply-function params-ah: (addr handle cell), args-ah: (addr handle cell), bo
return
}
#
evaluate-exprs body-ah, out, new-env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate-exprs body-ah, out, new-env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
}
fn evaluate-exprs _exprs-ah: (addr handle cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), call-number: int {
fn evaluate-exprs _exprs-ah: (addr handle cell), out: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), outer-screen: (addr screen), outer-keyboard: (addr keyboard), call-number: int {
# eval all exprs, writing result to `out` each time
var exprs-ah/ecx: (addr handle cell) <- copy _exprs-ah
$evaluate-exprs:loop: {
@ -700,7 +700,7 @@ fn evaluate-exprs _exprs-ah: (addr handle cell), out: (addr handle cell), env-h:
var curr-ah/eax: (addr handle cell) <- get exprs, left
debug-print "E", 7/fg, 0/bg
increment call-number
evaluate curr-ah, out, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate curr-ah, out, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "X", 7/fg, 0/bg
# errors? skip
{
@ -1425,7 +1425,7 @@ fn test-evaluate-is-well-behaved {
var tmp-storage: (handle cell)
var tmp-ah/edx: (addr handle cell) <- address tmp-storage
new-symbol tmp-ah, "a"
evaluate tmp-ah, tmp-ah, *env-ah, 0/no-globals, t, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, *env-ah, 0/no-globals, t, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
# doesn't die
check-trace-contains t, "error", "unbound symbol: a", "F - test-evaluate-is-well-behaved"
}
@ -1442,7 +1442,7 @@ fn test-evaluate-number {
var trace-storage: trace
var trace/edi: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp-ah, tmp-ah, *env-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, *env-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
#
var result/eax: (addr cell) <- lookup *tmp-ah
var result-type/edx: (addr int) <- get result, type
@ -1475,7 +1475,7 @@ fn test-evaluate-symbol {
var trace-storage: trace
var trace/edi: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp-ah, tmp-ah, *env-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, *env-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
var result/eax: (addr cell) <- lookup *tmp-ah
var result-type/edx: (addr int) <- get result, type
check-ints-equal *result-type, 1/number, "F - test-evaluate-symbol/0"
@ -1500,7 +1500,7 @@ fn test-evaluate-quote {
var trace-storage: trace
var trace/edi: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp-ah, tmp-ah, *nil-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, *nil-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
var result/eax: (addr cell) <- lookup *tmp-ah
var result-type/edx: (addr int) <- get result, type
check-ints-equal *result-type, 2/symbol, "F - test-evaluate-quote/0"
@ -1524,7 +1524,7 @@ fn test-evaluate-primitive-function {
var trace-storage: trace
var trace/edx: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate add-ah, tmp-ah, *nil-ah, globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate add-ah, tmp-ah, *nil-ah, globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
#
var result/eax: (addr cell) <- lookup *tmp-ah
var result-type/edx: (addr int) <- get result, type
@ -1559,7 +1559,7 @@ fn test-evaluate-primitive-function-call {
var globals/edx: (addr global-table) <- address globals-storage
initialize-globals globals
#
evaluate tmp-ah, tmp-ah, *nil-ah, globals, t, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, *nil-ah, globals, t, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
#? dump-trace t
#
var result/eax: (addr cell) <- lookup *tmp-ah
@ -1587,7 +1587,7 @@ fn test-evaluate-backquote {
var trace-storage: trace
var trace/edi: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp-ah, tmp2-ah, *nil-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp2-ah, *nil-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
var result/eax: (addr cell) <- lookup *tmp2-ah
var result-type/edx: (addr int) <- get result, type
check-ints-equal *result-type, 2/symbol, "F - test-evaluate-backquote/0"
@ -1595,7 +1595,7 @@ fn test-evaluate-backquote {
check sym?, "F - test-evaluate-backquote/1"
}
fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), call-number: int {
fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), inner-screen-var: (addr handle cell), inner-keyboard-var: (addr handle cell), definitions-created: (addr stream int), outer-screen: (addr screen), outer-keyboard: (addr keyboard), call-number: int {
# stack overflow? # disable when enabling Really-debug-print
#? dump-cell-from-cursor-over-full-screen _in-ah
check-stack
@ -1657,7 +1657,7 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e
var rest-ah/eax: (addr handle cell) <- get in, right
increment call-number
debug-print ",", 3/fg, 0/bg
evaluate rest-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate rest-ah, _out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print ",)", 3/fg, 0/bg
trace-higher trace
return
@ -1693,7 +1693,7 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e
trace-text trace, "eval", "unquote-splice"
var in-unquote-payload-ah/eax: (addr handle cell) <- get in-left, right
increment call-number
evaluate in-unquote-payload-ah, out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate in-unquote-payload-ah, out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
# errors? skip
{
var error?/eax: boolean <- has-errors? trace
@ -1715,7 +1715,7 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e
}
# append result of in-right
var in-right-ah/ecx: (addr handle cell) <- get in, right
evaluate-backquote in-right-ah, out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate-backquote in-right-ah, out-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
trace-higher trace
return
}
@ -1729,7 +1729,7 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e
var out/eax: (addr cell) <- lookup *out-ah
var out-left-ah/edx: (addr handle cell) <- get out, left
debug-print "`(l", 3/fg, 0/bg
evaluate-backquote in-left-ah, out-left-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate-backquote in-left-ah, out-left-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "`r)", 3/fg, 0/bg
# errors? skip
{
@ -1742,7 +1742,7 @@ fn evaluate-backquote _in-ah: (addr handle cell), _out-ah: (addr handle cell), e
var in-right-ah/ecx: (addr handle cell) <- get in, right
var out-right-ah/edx: (addr handle cell) <- get out, right
debug-print "`r(", 3/fg, 0/bg
evaluate-backquote in-right-ah, out-right-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, call-number
evaluate-backquote in-right-ah, out-right-ah, env-h, globals, trace, inner-screen-var, inner-keyboard-var, definitions-created, outer-screen, outer-keyboard, call-number
debug-print "`r)", 3/fg, 0/bg
trace-higher trace
}
@ -1770,7 +1770,7 @@ fn test-evaluate-backquote-list {
var trace-storage: trace
var trace/edi: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp-ah, tmp-ah, *nil-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, *nil-ah, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
# result is (a b)
var result/eax: (addr cell) <- lookup *tmp-ah
{
@ -1836,7 +1836,7 @@ fn test-evaluate-backquote-list-with-unquote {
var trace-storage: trace
var trace/edi: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp-ah, tmp-ah, env-h, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, env-h, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
# result is (a 3)
var result/eax: (addr cell) <- lookup *tmp-ah
{
@ -1910,7 +1910,7 @@ fn test-evaluate-backquote-list-with-unquote-splice {
var trace-storage: trace
var trace/edi: (addr trace) <- address trace-storage
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
evaluate tmp-ah, tmp-ah, env-h, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, env-h, 0/no-globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
# result is (a a 3 b)
#? dump-cell-from-cursor-over-full-screen tmp-ah
var result/eax: (addr cell) <- lookup *tmp-ah

View File

@ -290,7 +290,7 @@ fn refresh-definition _self: (addr global-table), _index: int {
var curr-value-ah/edi: (addr handle cell) <- get curr-global, value
var definitions-created-storage: (stream int 0x10)
var definitions-created/ecx: (addr stream int) <- address definitions-created-storage
read-and-evaluate-and-save-gap-buffer-to-globals curr-input-ah, curr-value-ah, self, definitions-created, curr-trace, 0/no-screen, 0/no-keyboard
read-and-evaluate-and-save-gap-buffer-to-globals curr-input-ah, curr-value-ah, self, definitions-created, curr-trace, 0/no-inner-screen-var, 0/no-inner-keyboard-var, 0/unused-outer-screen, 0/unused-outer-keyboard
}
fn assign-or-create-global _self: (addr global-table), name: (addr array byte), value: (handle cell), index-updated: (addr int), trace: (addr trace) {
@ -547,7 +547,7 @@ fn load-lexical-scope in-ah: (addr handle gap-buffer), _globals: (addr global-ta
initialize-trace trace, 1/only-errors, 0x10/capacity, 0/visible
var dummy-result-h: (handle cell)
var dummy-result-ah/ecx: (addr handle cell) <- address dummy-result-h
read-and-evaluate-and-save-gap-buffer-to-globals in-ah, dummy-result-ah, globals, definitions-created, trace, 0/no-inner-screen-var, 0/no-inner-keyboard-var
read-and-evaluate-and-save-gap-buffer-to-globals in-ah, dummy-result-ah, globals, definitions-created, trace, 0/no-inner-screen-var, 0/no-inner-keyboard-var, 0/unused-outer-screen, 0/unused-outer-keyboard
#
# save trace to all needed globals as well
rewind-stream definitions-created

View File

@ -269,7 +269,7 @@ fn macroexpand-iter _expr-ah: (addr handle cell), globals: (addr global-table),
var macro-definition-ah/eax: (addr handle cell) <- get definition, right
# TODO: check car(macro-definition) is litfn
#? turn-on-debug-print
apply macro-definition-ah, rest-ah, expr-ah, globals, trace, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
apply macro-definition-ah, rest-ah, expr-ah, globals, trace, 0/no-inner-screen-var, 0/no-inner-keyboard-var, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
trace-higher trace
# trace "1=> " _expr-ah {{{
{
@ -402,7 +402,7 @@ fn test-macroexpand {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "(define m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# invoke macro
initialize-sandbox-with sandbox, "(m 3 4)"
var gap-ah/ecx: (addr handle gap-buffer) <- get sandbox, data
@ -441,7 +441,7 @@ fn test-macroexpand-inside-anonymous-fn {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "(define m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# invoke macro
initialize-sandbox-with sandbox, "(fn() (m 3 4))"
var gap-ah/ecx: (addr handle gap-buffer) <- get sandbox, data
@ -479,7 +479,7 @@ fn test-macroexpand-inside-fn-call {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "(define m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# invoke macro
initialize-sandbox-with sandbox, "((fn() (m 3 4)))"
var gap-ah/ecx: (addr handle gap-buffer) <- get sandbox, data
@ -548,7 +548,7 @@ fn pending-test-macroexpand-inside-backquote-unquote {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "(define m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# invoke macro
initialize-sandbox-with sandbox, "`(print [result is ] ,(m 3 4)))"
var gap-ah/ecx: (addr handle gap-buffer) <- get sandbox, data
@ -586,7 +586,7 @@ fn pending-test-macroexpand-inside-nested-backquote-unquote {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "(define m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# invoke macro
initialize-sandbox-with sandbox, "`(a ,(m 3 4) `(b ,(m 3 4) ,,(m 3 4)))"
var gap-ah/ecx: (addr handle gap-buffer) <- get sandbox, data

View File

@ -14,7 +14,7 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
compare key, 0
loop-if-=
var key/eax: grapheme <- copy key
edit-environment env, key, data-disk
edit-environment env, key, data-disk, screen, keyboard
}
loop
}

View File

@ -508,7 +508,7 @@ fn test-evaluate-missing-arg-in-add {
var globals/edx: (addr global-table) <- address globals-storage
initialize-globals globals
#
evaluate tmp-ah, tmp-ah, *nil-ah, globals, t, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/call-number
evaluate tmp-ah, tmp-ah, *nil-ah, globals, t, 0/no-screen, 0/no-keyboard, 0/definitions-created, 0/unused-outer-screen, 0/unused-outer-keyboard, 0/call-number
# no crash
}

View File

@ -476,7 +476,7 @@ fn render-keyboard-menu screen: (addr screen) {
draw-text-rightward-from-cursor screen, " to sandbox ", width, 7/fg, 0xc5/bg=blue-bg
}
fn edit-sandbox _self: (addr sandbox), key: grapheme, globals: (addr global-table), data-disk: (addr disk) {
fn edit-sandbox _self: (addr sandbox), key: grapheme, globals: (addr global-table), data-disk: (addr disk), outer-screen: (addr screen), outer-keyboard: (addr keyboard) {
var self/esi: (addr sandbox) <- copy _self
# ctrl-s
{
@ -490,7 +490,7 @@ fn edit-sandbox _self: (addr sandbox), key: grapheme, globals: (addr global-tabl
# persisted until the next call to ctrl-s.
store-state data-disk, self, globals
#
run-sandbox self, globals
run-sandbox self, globals, outer-screen, outer-keyboard
return
}
# ctrl-m
@ -609,7 +609,7 @@ fn edit-sandbox _self: (addr sandbox), key: grapheme, globals: (addr global-tabl
# rerun at higher depth
var max-depth-addr/ecx: (addr int) <- get trace, max-depth
increment *max-depth-addr
run-sandbox self, globals
run-sandbox self, globals, outer-screen, outer-keyboard
# recompute cached indices
recompute-all-visible-lines trace
var save-addr/ecx: (addr trace-index-stash) <- address save
@ -620,7 +620,7 @@ fn edit-sandbox _self: (addr sandbox), key: grapheme, globals: (addr global-tabl
}
}
fn run-sandbox _self: (addr sandbox), globals: (addr global-table) {
fn run-sandbox _self: (addr sandbox), globals: (addr global-table), outer-screen: (addr screen), outer-keyboard: (addr keyboard) {
var self/esi: (addr sandbox) <- copy _self
var data-ah/ecx: (addr handle gap-buffer) <- get self, data
var eval-result-h: (handle cell)
@ -638,7 +638,7 @@ fn run-sandbox _self: (addr sandbox), globals: (addr global-table) {
var inner-keyboard-var/eax: (addr handle cell) <- get self, keyboard-var
rewind-keyboard-var inner-keyboard-var # don't clear keys from before
#
read-and-evaluate-and-save-gap-buffer-to-globals data-ah, eval-result-ah, globals, definitions-created, trace, inner-screen-var, inner-keyboard-var
read-and-evaluate-and-save-gap-buffer-to-globals data-ah, eval-result-ah, globals, definitions-created, trace, inner-screen-var, inner-keyboard-var, outer-screen, outer-keyboard
# if necessary, initialize a new gap-buffer for sandbox
{
compare globals, 0
@ -666,7 +666,7 @@ fn test-run-integer {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "1"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -684,7 +684,7 @@ fn test-run-negative-integer {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "-1"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -702,7 +702,7 @@ fn test-run-error-invalid-integer {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "1a"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -720,7 +720,7 @@ fn test-run-error-unknown-symbol {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "a"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -738,7 +738,7 @@ fn test-run-with-spaces {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, " 1 \n"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -757,7 +757,7 @@ fn test-run-quote {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "'a"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -775,7 +775,7 @@ fn test-run-dotted-list {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "'(a . b)"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -793,7 +793,7 @@ fn test-run-dot-and-list {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "'(a . (b))"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -811,7 +811,7 @@ fn test-run-final-dot {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "'(a .)"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -830,7 +830,7 @@ fn test-run-double-dot {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "'(a . .)"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -849,7 +849,7 @@ fn test-run-multiple-expressions-after-dot {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "'(a . b c)"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -868,7 +868,7 @@ fn test-run-stream {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "[a b]"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -886,7 +886,7 @@ fn test-run-move-cursor-into-trace {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "12"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -901,7 +901,7 @@ fn test-run-move-cursor-into-trace {
check-screen-row screen, 3/y, " => 12 ", "F - test-run-move-cursor-into-trace/pre-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-move-cursor-into-trace/pre-2/cursor"
# move cursor into trace
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
# skip one line of padding
@ -912,7 +912,7 @@ fn test-run-move-cursor-into-trace {
check-screen-row screen, 3/y, " => 12 ", "F - test-run-move-cursor-into-trace/trace-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-move-cursor-into-trace/trace-2/cursor"
# move cursor into input
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
# skip one line of padding
@ -948,7 +948,7 @@ fn test-run-expand-trace {
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "12"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -963,7 +963,7 @@ fn test-run-expand-trace {
check-screen-row screen, 3/y, " => 12 ", "F - test-run-expand-trace/pre0-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-expand-trace/pre0-2/cursor"
# move cursor into trace
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
# skip one line of padding
@ -974,7 +974,7 @@ fn test-run-expand-trace {
check-screen-row screen, 3/y, " => 12 ", "F - test-run-expand-trace/pre1-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-expand-trace/pre1-2/cursor"
# expand
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
#
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
@ -995,7 +995,7 @@ fn test-run-can-rerun-when-expanding-trace {
# initialize sandbox with a max-depth of 3
initialize-sandbox-with sandbox, "12"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -1010,7 +1010,7 @@ fn test-run-can-rerun-when-expanding-trace {
check-screen-row screen, 3/y, " => 12 ", "F - test-run-can-rerun-when-expanding-trace/pre0-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-can-rerun-when-expanding-trace/pre0-2/cursor"
# move cursor into trace
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
# skip one line of padding
@ -1021,7 +1021,7 @@ fn test-run-can-rerun-when-expanding-trace {
check-screen-row screen, 3/y, " => 12 ", "F - test-run-can-rerun-when-expanding-trace/pre1-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-can-rerun-when-expanding-trace/pre1-2/cursor"
# expand
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
#
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
@ -1035,9 +1035,9 @@ fn test-run-can-rerun-when-expanding-trace {
check-screen-row screen, 4/y, " 1 pars", "F - test-run-can-rerun-when-expanding-trace/pre2-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 4/y, " ", "F - test-run-can-rerun-when-expanding-trace/pre2-2/cursor"
# move cursor down and expand
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
#
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
@ -1060,7 +1060,7 @@ fn test-run-preserves-trace-view-on-rerun {
# initialize sandbox with a max-depth of 3
initialize-sandbox-with sandbox, "7"
# eval
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -1075,7 +1075,7 @@ fn test-run-preserves-trace-view-on-rerun {
check-screen-row screen, 3/y, " => 7 ", "F - test-run-preserves-trace-view-on-rerun/pre0-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-preserves-trace-view-on-rerun/pre0-2/cursor"
# move cursor into trace
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
#
check-screen-row screen, 1/y, " 7 ", "F - test-run-preserves-trace-view-on-rerun/pre1-0"
@ -1085,7 +1085,7 @@ fn test-run-preserves-trace-view-on-rerun {
check-screen-row screen, 3/y, " => 7 ", "F - test-run-preserves-trace-view-on-rerun/pre1-2"
check-background-color-in-screen-row screen, 7/bg=cursor, 3/y, " ", "F - test-run-preserves-trace-view-on-rerun/pre1-2/cursor"
# expand
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
#
@ -1106,15 +1106,15 @@ fn test-run-preserves-trace-view-on-rerun {
check-screen-row screen, 8/y, " 1 => 7 ", "F - test-run-preserves-trace-view-on-rerun/pre2-7"
check-background-color-in-screen-row screen, 7/bg=cursor, 8/y, " ", "F - test-run-preserves-trace-view-on-rerun/pre2-7/cursor"
# move cursor down below the macroexpand line and expand
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
#
check-screen-row screen, 1/y, " 7 ", "F - test-run-preserves-trace-view-on-rerun/pre3-0"
@ -1134,7 +1134,7 @@ fn test-run-preserves-trace-view-on-rerun {
check-screen-row screen, 8/y, " 1 => 7 ", "F - test-run-preserves-trace-view-on-rerun/pre3-7"
check-background-color-in-screen-row screen, 7/bg=cursor, 8/y, " ", "F - test-run-preserves-trace-view-on-rerun/pre3-7/cursor"
# expand
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/unused-outer-screen, 0/unused-outer-keyboard
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height, 1/show-cursor
# cursor line is expanded