diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/evaluate.mu | 63 | ||||
-rw-r--r-- | shell/global.mu | 1 |
2 files changed, 62 insertions, 2 deletions
diff --git a/shell/evaluate.mu b/shell/evaluate.mu index 79204bd7..0248b3f7 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -4,8 +4,9 @@ # 'call-number' is just for showing intermediate progress; this is a _slow_ interpreter fn evaluate _in: (addr handle cell), out: (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 - show-stack-state +#? check-stack +#? show-stack-state + debug-print "^", 7/fg, 0/bg # errors? skip { compare trace, 0 @@ -54,6 +55,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel trace trace, "eval", stream } # }}} + debug-print "!", 7/fg, 0/bg trace-lower trace var in-addr/eax: (addr cell) <- lookup *in { @@ -66,6 +68,7 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel trace-higher trace return } + debug-print "@", 7/fg, 0/bg var in-type/ecx: (addr int) <- get in-addr, type compare *in-type, 1/number { @@ -211,6 +214,12 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel compare set?, 0/false break-if-= # + { + var foo/eax: boolean <- debug-print? + compare foo, 0/false + break-if-= + draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "set|", 7/fg, 0/bg + } trace-text trace, "eval", "set" trace-text trace, "eval", "evaluating second arg" var rest/eax: (addr cell) <- lookup *rest-ah @@ -308,17 +317,60 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel rest-ah <- get rest, right var guard-h: (handle cell) var guard-ah/esi: (addr handle cell) <- address guard-h + # skip first 201 iterations without debug + var i/ebx: int <- copy 0 + { + 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, screen-cell, keyboard-cell, call-number + debug-print "W", 4/fg, 0/bg + var guard-a/eax: (addr cell) <- lookup *guard-ah + var done?/eax: boolean <- nil? guard-a + compare done?, 0/false + break-if-!= + evaluate-exprs rest-ah, out, env-h, globals, trace, screen-cell, keyboard-cell, call-number + i <- increment + compare i, 0xc9/201 + break-if-> + loop + } + turn-on-debug-print + i <- copy 0 { trace-text trace, "eval", "loop termination check" + { + compare trace, 0 + break-if-= + var error?/eax: boolean <- has-errors? trace + compare error?, 0/false + break-if-= + return + } + set-cursor-position 0/screen, 0/x, i + i <- increment + compare i, 0x20 + { + break-if-< + clear-screen 0/screen + i <- copy 0 + set-cursor-position 0/screen, 0/x, i + } debug-print "V", 4/fg, 0/bg increment call-number + dump-cell-from-cursor-over-full-screen first-arg-ah + draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "|", 7/fg, 0/bg evaluate first-arg-ah, guard-ah, env-h, globals, trace, screen-cell, keyboard-cell, call-number debug-print "W", 4/fg, 0/bg + dump-cell-from-cursor-over-full-screen guard-ah + draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "|", 7/fg, 0/bg var guard-a/eax: (addr cell) <- lookup *guard-ah var done?/eax: boolean <- nil? guard-a compare done?, 0/false break-if-!= + dump-cell-from-cursor-over-full-screen rest-ah evaluate-exprs rest-ah, out, env-h, globals, trace, screen-cell, keyboard-cell, call-number + draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "]", 7/fg, 0/bg loop } trace-text trace, "eval", "loop terminated" @@ -453,6 +505,13 @@ fn evaluate-exprs _exprs-ah: (addr handle cell), out: (addr handle cell), env-h: debug-print "E", 7/fg, 0/bg increment call-number evaluate curr-ah, out, env-h, globals, trace, screen-cell, keyboard-cell, call-number + { + var foo/eax: boolean <- debug-print? + compare foo, 0/false + break-if-= + dump-cell-from-cursor-over-full-screen out + draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "|", 7/fg, 0/bg + } debug-print "X", 7/fg, 0/bg } # diff --git a/shell/global.mu b/shell/global.mu index 649964b7..eab66bbe 100644 --- a/shell/global.mu +++ b/shell/global.mu @@ -1314,6 +1314,7 @@ fn apply-print _args-ah: (addr handle cell), out: (addr handle cell), trace: (ad var stream-storage: (stream byte 0x100) var stream/edi: (addr stream byte) <- address stream-storage print-cell second-ah, stream, trace + set-cursor-position screen, 0, 0 draw-stream-wrapping-right-then-down-from-cursor-over-full-screen screen, stream, 7/fg, 0/bg # return what was printed copy-object second-ah, out |