This commit is contained in:
Kartik K. Agaram 2021-05-31 12:56:15 -07:00
parent 82171a0fdf
commit ee536ff3e8
4 changed files with 36 additions and 34 deletions

View File

@ -2,6 +2,7 @@
# we never modify `_in-ah` or `env`
# ignore args past 'trace' on a first reading; they're for the environment not the language
# 'call-number' is just for showing intermediate progress; this is a _slow_ interpreter
# side-effect: prints to real screen if not in a test (screen-cell != 0)
fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (handle cell), globals: (addr global-table), trace: (addr trace), screen-cell: (addr handle cell), keyboard-cell: (addr handle cell), call-number: int {
# stack overflow? # disable when enabling Really-debug-print
check-stack
@ -24,6 +25,7 @@ fn evaluate _in-ah: (addr handle cell), _out-ah: (addr handle cell), env-h: (han
}
var in-ah/esi: (addr handle cell) <- copy _in-ah
# show intermediate progress on screen if necessary
# treat input at the real keyboard as interrupting
{
compare screen-cell, 0
break-if-=

View File

@ -402,7 +402,7 @@ fn test-macroexpand {
var sandbox-storage: sandbox
var sandbox/esi: (addr sandbox) <- address sandbox-storage
initialize-sandbox-with sandbox, "(def m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-tweak-screen
# 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, "(def m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-tweak-screen
# 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, "(def m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-tweak-screen
# 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, "(def m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-tweak-screen
# 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, "(def m (litmac litfn () (a b) `(+ ,a ,b)))"
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, globals, 0/no-disk, 0/no-tweak-screen
# 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

@ -69,7 +69,7 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
loop $main:loop
}
# no way to quit right now; just reboot
edit-sandbox sandbox, key, globals, data-disk, screen, 1/tweak-real-screen
edit-sandbox sandbox, key, globals, data-disk, 1/tweak-real-screen
}
loop
}

View File

@ -459,7 +459,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: byte, globals: (addr global-table), data-disk: (addr disk), real-screen: (addr screen), tweak-real-screen?: boolean {
fn edit-sandbox _self: (addr sandbox), key: byte, globals: (addr global-table), data-disk: (addr disk), tweak-real-screen?: boolean {
var self/esi: (addr sandbox) <- copy _self
var g/edx: grapheme <- copy key
# ctrl-s
@ -474,7 +474,7 @@ fn edit-sandbox _self: (addr sandbox), key: byte, globals: (addr global-table),
# persisted until the next call to ctrl-s.
store-state data-disk, self, globals
#
run-sandbox self, globals, real-screen, tweak-real-screen?
run-sandbox self, globals, tweak-real-screen?
return
}
# ctrl-m
@ -587,7 +587,7 @@ fn edit-sandbox _self: (addr sandbox), key: byte, globals: (addr global-table),
break-if-=
var max-depth-addr/eax: (addr int) <- get trace, max-depth
increment *max-depth-addr
run-sandbox self, globals, real-screen, tweak-real-screen?
run-sandbox self, globals, tweak-real-screen?
}
edit-trace trace, g
return
@ -595,7 +595,7 @@ fn edit-sandbox _self: (addr sandbox), key: byte, globals: (addr global-table),
}
# hack: tweak-real-screen guards things there are no tests for
fn run-sandbox _self: (addr sandbox), globals: (addr global-table), real-screen: (addr screen), tweak-real-screen?: boolean {
fn run-sandbox _self: (addr sandbox), globals: (addr global-table), tweak-real-screen?: boolean {
var self/esi: (addr sandbox) <- copy _self
var data-ah/ecx: (addr handle gap-buffer) <- get self, data
var value-ah/eax: (addr handle stream byte) <- get self, value
@ -608,7 +608,7 @@ fn run-sandbox _self: (addr sandbox), globals: (addr global-table), real-screen:
{
compare tweak-real-screen?, 0/false
break-if-=
clear-sandbox-output real-screen, self, 0x56/sandbox-left-margin, 1/y, 0x80/screen-width, 0x2f/screen-height-without-menu
clear-sandbox-output 0/screen, self, 0x56/sandbox-left-margin, 1/y, 0x80/screen-width, 0x2f/screen-height-without-menu
}
var screen-cell/eax: (addr handle cell) <- get self, screen-var
clear-screen-cell screen-cell
@ -617,7 +617,7 @@ fn run-sandbox _self: (addr sandbox), globals: (addr global-table), real-screen:
{
compare tweak-real-screen?, 0/false
break-if-=
set-cursor-position real-screen, 0/x, 0/y # for any debug prints during evaluation
set-cursor-position 0/screen, 0/x, 0/y # for any debug prints during evaluation
}
run data-ah, value, globals, trace, screen-cell, keyboard-cell
}
@ -707,7 +707,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -725,7 +725,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -743,7 +743,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -761,7 +761,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -780,7 +780,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -798,7 +798,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -816,7 +816,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -834,7 +834,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -853,7 +853,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -872,7 +872,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -891,7 +891,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -909,7 +909,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -924,7 +924,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/no-tweak-screen
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
# skip one line of padding
@ -935,7 +935,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/no-tweak-screen
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
# skip one line of padding
@ -971,7 +971,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -986,7 +986,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/no-tweak-screen
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
# skip one line of padding
@ -997,7 +997,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/no-tweak-screen
#
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
@ -1018,7 +1018,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x13/ctrl-s, 0/no-globals, 0/no-disk, 0/no-tweak-screen
# setup: screen
var screen-on-stack: screen
var screen/edi: (addr screen) <- address screen-on-stack
@ -1033,7 +1033,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/no-tweak-screen
#
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
# skip one line of padding
@ -1044,7 +1044,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/no-tweak-screen
#
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
@ -1058,9 +1058,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, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0x6a/j, 0/no-globals, 0/no-disk, 0/no-tweak-screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
edit-sandbox sandbox, 0xa/newline, 0/no-globals, 0/no-disk, 0/no-tweak-screen
#
clear-screen screen
render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height