diff options
-rw-r--r-- | editor/mu.vim | 2 | ||||
-rw-r--r-- | shell/evaluate.mu | 2 | ||||
-rw-r--r-- | shell/global.mu | 4 | ||||
-rw-r--r-- | shell/parse.mu | 2 | ||||
-rw-r--r-- | shell/sandbox.mu | 24 | ||||
-rw-r--r-- | shell/trace.mu | 14 |
6 files changed, 40 insertions, 8 deletions
diff --git a/editor/mu.vim b/editor/mu.vim index ba93a196..374d6e5d 100644 --- a/editor/mu.vim +++ b/editor/mu.vim @@ -49,7 +49,7 @@ highlight link muError Error " sources of action at a distance syntax match muAssign "<-" highlight link muAssign SpecialChar -syntax keyword muAssign error +syntax keyword muAssign error error-stream highlight link muAssign Special " common keywords diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 8d897492..d4e92373 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -819,7 +819,7 @@ fn lookup-symbol sym: (addr cell), out: (addr handle cell), env-h: (handle cell) trace-lower trace var _env/eax: (addr cell) <- lookup env-h var env/ebx: (addr cell) <- copy _env - # if env is not a list, abort + # if env is not a list, error { var env-type/ecx: (addr int) <- get env, type compare *env-type, 0/pair diff --git a/shell/global.mu b/shell/global.mu index 219ac5e3..6e0ff806 100644 --- a/shell/global.mu +++ b/shell/global.mu @@ -395,7 +395,7 @@ fn lookup-symbol-in-globals _sym: (addr cell), out: (addr handle cell), _globals write stream, "unbound symbol: " rewind-stream sym-name write-stream stream, sym-name - trace trace, "error", stream + error-stream trace, stream } fn maybe-lookup-symbol-in-globals _sym: (addr cell), out: (addr handle cell), _globals: (addr global-table), trace: (addr trace) { @@ -506,7 +506,7 @@ fn mutate-binding-in-globals name: (addr stream byte), val: (addr handle cell), write stream, "unbound symbol: " rewind-stream name write-stream stream, name - trace trace, "error", stream + error-stream trace, stream } # a little strange; goes from value to name and selects primitive based on name diff --git a/shell/parse.mu b/shell/parse.mu index bcaedd21..f59c5488 100644 --- a/shell/parse.mu +++ b/shell/parse.mu @@ -192,7 +192,7 @@ fn parse-sexpression tokens: (addr stream cell), _out: (addr handle cell), trace var curr-token-data/eax: (addr stream byte) <- lookup *curr-token-data-ah rewind-stream curr-token-data write-stream stream, curr-token-data - trace trace, "error", stream + error-stream trace, stream } trace-higher trace return 0/false, 0/false diff --git a/shell/sandbox.mu b/shell/sandbox.mu index 12c9e7e6..87cebfe6 100644 --- a/shell/sandbox.mu +++ b/shell/sandbox.mu @@ -720,9 +720,27 @@ fn test-run-error-invalid-integer { # render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height # skip one line of padding - check-screen-row screen, 1/y, " 1a ", "F - test-run-error-invalid-integer/0" - check-screen-row screen, 2/y, " ... ", "F - test-run-error-invalid-integer/0" - check-screen-row screen, 3/y, " invalid number ", "F - test-run-error-invalid-integer/2" + check-screen-row screen, 1/y, " 1a ", "F - test-run-error-invalid-integer/0" + check-screen-row screen, 2/y, " ... ", "F - test-run-error-invalid-integer/1" + check-screen-row-in-color screen, 0xc/fg=error, 3/y, " invalid number ", "F - test-run-error-invalid-integer/2" +} + +fn test-run-error-unknown-symbol { + var sandbox-storage: sandbox + 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 + # setup: screen + var screen-on-stack: screen + var screen/edi: (addr screen) <- address screen-on-stack + initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics + # + render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height + # skip one line of padding + check-screen-row screen, 1/y, " a ", "F - test-run-error-unknown-symbol/0" + check-screen-row screen, 2/y, " ... ", "F - test-run-error-unknown-symbol/1" + check-screen-row-in-color screen, 0xc/fg=error, 3/y, " unbound symbol: a ", "F - test-run-error-unknown-symbol/2" } fn test-run-with-spaces { diff --git a/shell/trace.mu b/shell/trace.mu index 22c01269..85ca117b 100644 --- a/shell/trace.mu +++ b/shell/trace.mu @@ -195,6 +195,20 @@ fn error _self: (addr trace), message: (addr array byte) { copy-to *curr-depth-a, save-depth } +fn error-stream _self: (addr trace), message: (addr stream byte) { + var self/esi: (addr trace) <- copy _self + compare self, 0 + { + break-if-!= + abort "null trace" + } + var curr-depth-a/eax: (addr int) <- get self, curr-depth + var save-depth/ecx: int <- copy *curr-depth-a + copy-to *curr-depth-a, 0/error + trace self, "error", message + copy-to *curr-depth-a, save-depth +} + fn initialize-trace-line depth: int, label: (addr array byte), data: (addr stream byte), _out: (addr trace-line) { var out/edi: (addr trace-line) <- copy _out # depth |