diff options
-rw-r--r-- | mu.arc | 5 | ||||
-rw-r--r-- | trace.arc.t | 278 | ||||
-rw-r--r-- | trace.mu | 93 |
3 files changed, 333 insertions, 43 deletions
diff --git a/mu.arc b/mu.arc index 40b09bec..ee59472b 100644 --- a/mu.arc +++ b/mu.arc @@ -2787,8 +2787,11 @@ { begin (break-unless x:terminal-address) (row:integer-address <- get-address x:terminal-address/deref cursor-row:offset) -;? ($print row:integer-address/deref) ;? 1 +;? ($print row:integer-address/deref) ;? 2 +;? ($print ((", " literal))) ;? 1 (col:integer-address <- get-address x:terminal-address/deref cursor-col:offset) +;? ($print col:integer-address/deref) ;? 1 +;? ($print (("\n" literal))) ;? 1 (width:integer <- get x:terminal-address/deref num-cols:offset) (t1:integer <- multiply row:integer-address/deref width:integer) (idx:integer <- add t1:integer col:integer-address/deref) diff --git a/trace.arc.t b/trace.arc.t index 33c37245..4d8cd69c 100644 --- a/trace.arc.t +++ b/trace.arc.t @@ -1004,5 +1004,283 @@ run: main 7: n") " ")) (prn "F - page-up 5")) +; page-up scenario 6 +; + run: main 0: a b c +; mem: 0 a +; - run: main 1: d e f +; mem: 1 a +; mem: 1 b <- top of page +; mem: 1 c +; mem: 1 d <- bottom of page +; mem: 1 e +; + run: main 2: g hi +; + run: main 3: j +; mem: 3 a +; + run: main 4: k +; + run: main 5: l +; + run: main 6: m +; + run: main 7: n +(run-code main17 + (default-space:space-address <- new space:literal 30:literal/capacity) + (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state) + (first-index-on-page:integer/space:1 <- copy 1:literal) + (first-subindex-on-page:integer/space:1 <- copy 1:literal) + (last-index-on-page:integer/space:1 <- copy 1:literal) + (last-subindex-on-page:integer/space:1 <- copy 3:literal) + (expanded-index:integer/space:1 <- copy 1:literal) + (expanded-children:integer/space:1 <- copy 5:literal) + (s:string-address <- new "K") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~screen-contains memory*.4 17 + (+ "+ main/ 0 : a b c" + "- main/ 1 : d e f" + " mem : 1 a " + " " + " ")) + (prn "F - page-up 6")) + +; page-up scenario 7 +; + run: main 0: a b c +; mem: 0 a +; + run: main 1: d e f <- top of page +; mem: 1 a +; mem: 1 b +; mem: 1 c +; mem: 1 d +; mem: 1 e +; + run: main 2: g hi +; - run: main 3: j <- bottom of page +; mem: 3 a +; + run: main 4: k +; + run: main 5: l +; + run: main 6: m +; + run: main 7: n +(run-code main18 + (default-space:space-address <- new space:literal 30:literal/capacity) + (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state) + (first-index-on-page:integer/space:1 <- copy 1:literal) + (first-subindex-on-page:integer/space:1 <- copy -2:literal) + (last-index-on-page:integer/space:1 <- copy 3:literal) + (last-subindex-on-page:integer/space:1 <- copy -1:literal) + (expanded-index:integer/space:1 <- copy 3:literal) + (expanded-children:integer/space:1 <- copy 1:literal) + (s:string-address <- new "K") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~screen-contains memory*.4 17 + (+ "+ main/ 0 : a b c" + "+ main/ 1 : d e f" + "+ main/ 2 : g hi " + " ")) + (prn "F - page-up 7 - expanded index starts below bottom")) +;? (quit) ;? 1 + +; page-up scenario 8 +; + run: main 0: a b c +; mem: 0 a +; + run: main 1: d e f <- top of page +; mem: 1 a +; mem: 1 b +; mem: 1 c +; mem: 1 d +; mem: 1 e +; + run: main 2: g hi +; + run: main 3: j <- bottom of page +; mem: 3 a +; - run: main 4: k +; + run: main 5: l +; + run: main 6: m +; + run: main 7: n +(run-code main19 + (default-space:space-address <- new space:literal 30:literal/capacity) + (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state) + (first-index-on-page:integer/space:1 <- copy 1:literal) + (first-subindex-on-page:integer/space:1 <- copy -2:literal) + (last-index-on-page:integer/space:1 <- copy 3:literal) + (last-subindex-on-page:integer/space:1 <- copy -1:literal) + (expanded-index:integer/space:1 <- copy 4:literal) + (expanded-children:integer/space:1 <- copy 0:literal) + (s:string-address <- new "K") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~screen-contains memory*.4 17 + (+ "+ main/ 0 : a b c" + "+ main/ 1 : d e f" + "+ main/ 2 : g hi " + " ")) + (prn "F - page-up 8 - expanded index starts below top - 2")) + +; page-up scenario 9 +; - run: main 0: a b c +; mem: 0 a +; + run: main 1: d e f +; mem: 1 a +; mem: 1 b +; mem: 1 c +; mem: 1 d +; mem: 1 e +; + run: main 2: g hi +; + run: main 3: j <- top of page +; mem: 3 a +; + run: main 4: k +; + run: main 5: l <- bottom of page +; + run: main 6: m +; + run: main 7: n +(run-code main20 + (default-space:space-address <- new space:literal 30:literal/capacity) + (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state) + (first-index-on-page:integer/space:1 <- copy 3:literal) + (first-subindex-on-page:integer/space:1 <- copy -2:literal) + (last-index-on-page:integer/space:1 <- copy 5:literal) + (last-subindex-on-page:integer/space:1 <- copy -2:literal) + (expanded-index:integer/space:1 <- copy 0:literal) + (expanded-children:integer/space:1 <- copy 1:literal) + (s:string-address <- new "K") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~screen-contains memory*.4 17 + (+ " mem : 0 a " + "+ main/ 1 : d e f" + "+ main/ 2 : g hi " + " ")) + (prn "F - page-up 9 - expanded index overlaps target page")) + +; page-up scenario 10 +; - run: main 0: a b c +; mem: 0 a +; + run: main 1: d e f +; mem: 1 a +; mem: 1 b +; mem: 1 c +; mem: 1 d +; mem: 1 e +; + run: main 2: g hi <- top of page +; + run: main 3: j +; mem: 3 a +; + run: main 4: k <- bottom of page +; + run: main 5: l +; + run: main 6: m +; + run: main 7: n +(run-code main21pre + (default-space:space-address <- new space:literal 30:literal/capacity) + (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state) + (first-index-on-page:integer/space:1 <- copy 2:literal) + (first-subindex-on-page:integer/space:1 <- copy -2:literal) + (last-index-on-page:integer/space:1 <- copy 4:literal) + (last-subindex-on-page:integer/space:1 <- copy -2:literal) + (expanded-index:integer/space:1 <- copy 0:literal) + (expanded-children:integer/space:1 <- copy 1:literal) + (to-top 0:space-address/browser-state 2:terminal-address/raw) +;? ($start-tracing) ;? 2 + (print-page 0:space-address/browser-state 2:terminal-address/raw) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~screen-contains memory*.4 17 + (+ "+ main/ 2 : g hi " + "+ main/ 3 : j " + "+ main/ 4 : k " + " " + " ")) + (prn "F - page-up 10: initial print-page state")) +;? (quit) ;? 1 +(run-code main21 + (default-space:space-address <- new space:literal 30:literal/capacity) + (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state) + (first-index-on-page:integer/space:1 <- copy 2:literal) + (first-subindex-on-page:integer/space:1 <- copy -2:literal) + (last-index-on-page:integer/space:1 <- copy 4:literal) + (last-subindex-on-page:integer/space:1 <- copy -2:literal) + (expanded-index:integer/space:1 <- copy 0:literal) + (expanded-children:integer/space:1 <- copy 1:literal) + (s:string-address <- new "K") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~screen-contains memory*.4 17 + (+ "- main/ 0 : a b c" + " mem : 0 a " + "+ main/ 1 : d e f" + " " + " ")) + (prn "F - page-up 10 - expanded index overlaps target page - 2")) +;? (quit) ;? 1 + +(reset2) +(new-trace "trace-paginate2") +; page-up scenario 11 +; + run: main 0: a b c +; mem: 0 a +; + run: main 1: d e f +; - run: main 2: g hi +; mem: 2 a +; + run: main 3: j <- top of page +; mem: 3 a +; + run: main 4: k +; + run: main 5: l <- bottom of page +; + run: main 6: m +; + run: main 7: n +(run-code main22 + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:string-address <- new +"run: main 0: a b c +mem: 0 a +run: main 1: d e f +run: main 2: g hi +mem: 2 a +run: main 3: j +mem: 3 a +run: main 4: k +run: main 5: l +run: main 6: m +run: main 7: n") + (s:stream-address <- init-stream x:string-address) + (traces:instruction-trace-address-array-address <- parse-traces s:stream-address) + (2:terminal-address/raw <- init-fake-terminal 17:literal 15:literal) + (3:space-address/raw/browser-state <- browser-state traces:instruction-trace-address-array-address 3:literal/screen-height) + (0:space-address/names:browser-state <- copy 3:space-address/raw/browser-state) + (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset) + (first-index-on-page:integer/space:1 <- copy 3:literal) + (first-subindex-on-page:integer/space:1 <- copy -2:literal) + (last-index-on-page:integer/space:1 <- copy 5:literal) + (last-subindex-on-page:integer/space:1 <- copy -2:literal) + (expanded-index:integer/space:1 <- copy 2:literal) + (expanded-children:integer/space:1 <- copy 1:literal) + (s:string-address <- new "K") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw) + ) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~screen-contains memory*.4 17 + (+ "+ main/ 1 : d e f" + "- main/ 2 : g hi " + " mem : 2 a " + " " + " ")) + (prn "F - page-up 11 - expanded index overlaps target page - 3")) + (reset2) ;? (print-times) ;? 3 diff --git a/trace.mu b/trace.mu index 300ae35f..7db6adfe 100644 --- a/trace.mu +++ b/trace.mu @@ -477,27 +477,27 @@ (function print-page [ (default-space:space-address <- new space:literal 30:literal/capacity) (0:space-address/names:browser-state <- next-input) -;? ($print (("print-page " literal))) ;? 1 -;? ($print first-index-on-page:integer/space:1) ;? 1 -;? ($print ((" " literal))) ;? 1 -;? ($print first-subindex-on-page:integer/space:1) ;? 1 -;? ($print (("\n" literal))) ;? 1 +;? ($print (("print-page " literal))) ;? 3 +;? ($print first-index-on-page:integer/space:1) ;? 3 +;? ($print ((" " literal))) ;? 3 +;? ($print first-subindex-on-page:integer/space:1) ;? 3 +;? ($print (("\n" literal))) ;? 3 (screen:terminal-address <- next-input) -;? ($dump-browser-state 0:space-address/browser-state) ;? 1 +;? ($dump-browser-state 0:space-address/browser-state) ;? 2 ; if top inside expanded index, complete existing trace (first-full-index:integer <- copy first-index-on-page:integer/space:1) -;? ($print first-full-index:integer) ;? 1 -;? ($print cursor-row:integer/space:1) ;? 1 +;? ($print first-full-index:integer) ;? 2 +;? ($print cursor-row:integer/space:1) ;? 2 { begin (screen-done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1) (break-unless screen-done?:boolean) (reply) } -;? ($print (("\nAAA\n" literal))) ;? 2 +;? ($print (("\nAAA\n" literal))) ;? 3 { begin (partial-trace?:boolean <- equal first-index-on-page:integer/space:1 expanded-index:integer/space:1) (break-unless partial-trace?:boolean) -;? ($print (("AAA: partial\n" literal))) ;? 2 +;? ($print (("AAA: partial\n" literal))) ;? 3 (first-full-index:integer <- add first-full-index:integer 1:literal) (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref first-index-on-page:integer/space:1) { begin @@ -515,7 +515,7 @@ ; or screen ends (screen-done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1) (break-if screen-done?:boolean) -;? ($print (("AAA printing subtrace\n" literal))) ;? 1 +;? ($print (("AAA printing subtrace\n" literal))) ;? 2 (t:trace-address <- index ch:trace-address-array-address/deref i:integer) (print-character screen:terminal-address ((#\space literal))) (print-character screen:terminal-address ((#\space literal))) @@ -527,19 +527,19 @@ (loop) } } -;? ($print (("AAA 3: " literal))) ;? 3 -;? ($print cursor-row:integer/space:1) ;? 2 -;? ($print (("\n" literal))) ;? 2 +;? ($print (("AAA 3: " literal))) ;? 4 +;? ($print cursor-row:integer/space:1) ;? 3 +;? ($print (("\n" literal))) ;? 3 { begin (screen-done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1) (break-unless screen-done?:boolean) (reply) } -;? ($print (("AAA 4\n" literal))) ;? 3 +;? ($print (("AAA 4\n" literal))) ;? 4 { begin (has-expanded?:boolean <- greater-or-equal expanded-index:integer/space:1 0:literal) (break-if has-expanded?:boolean) -;? ($print (("AAA 5a\n" literal))) ;? 2 +;? ($print (("AAA 5a\n" literal))) ;? 3 (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer) (clear-rest-of-page 0:space-address/browser-state screen:terminal-address) (reply) @@ -547,19 +547,23 @@ { begin (below-expanded?:boolean <- greater-than first-full-index:integer expanded-index:integer/space:1) (break-unless below-expanded?:boolean) -;? ($print (("AAA 5b\n" literal))) ;? 2 +;? ($print (("AAA 5b\n" literal))) ;? 3 (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer) (clear-rest-of-page 0:space-address/browser-state screen:terminal-address) (reply) } ; trace has an expanded index and it's below first-full-index ; print traces collapsed until expanded index -;? ($print (("AAA 5c\n" literal))) ;? 2 +;? ($print (("AAA 5c\n" literal))) ;? 3 (print-traces-collapsed-from 0:space-address/browser-state screen:terminal-address first-full-index:integer expanded-index:integer/space:1/until) ; if room, start printing expanded index - (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref expanded-index:integer/space:1) - (print-instruction-trace screen:terminal-address tr:instruction-trace-address 0:space-address/browser-state) - (clear-rest-of-page 0:space-address/browser-state screen:terminal-address) + { begin + (done?:boolean <- greater-or-equal cursor-row:integer/space:1 screen-height:integer/space:1) + (break-if done?:boolean) + (tr:instruction-trace-address <- index traces:instruction-trace-address-array-address/space:1/deref expanded-index:integer/space:1) + (print-instruction-trace screen:terminal-address tr:instruction-trace-address 0:space-address/browser-state) + (clear-rest-of-page 0:space-address/browser-state screen:terminal-address) + } ]) (function cursor-row-to-trace-index [ @@ -805,71 +809,76 @@ ;? ($print (("\n" literal))) ;? 2 ; easy case: no expanded-index (jump-unless expanded-index:integer/space:1) -;? ($print (("b\n" literal))) ;? 3 +;? ($print (("b\n" literal))) ;? 4 (x:boolean <- less-than expanded-index:integer/space:1 0:literal) (jump-if x:boolean easy-case:offset) ; easy case: expanded-index lies below top of current page -;? ($print (("c\n" literal))) ;? 3 +;? ($print (("c\n" literal))) ;? 4 (x:boolean <- greater-than expanded-index:integer/space:1 first-index-on-page:integer/space:1) (jump-if x:boolean easy-case:offset) ; easy case: expanded-index *starts* at top of current page -;? ($print (("d\n" literal))) ;? 4 +;? ($print (("d\n" literal))) ;? 5 (top-of-screen-inside-expanded:boolean <- equal expanded-index:integer/space:1 first-index-on-page:integer/space:1) (y:boolean <- lesser-or-equal first-subindex-on-page:integer/space:1 -1:literal) (y:boolean <- and top-of-screen-inside-expanded:boolean y:boolean) (jump-if y:boolean easy-case:offset) ; easy case: expanded-index too far up for previous page -;? ($print (("e\n" literal))) ;? 4 +;? ($print (("e\n" literal))) ;? 5 (delta-to-expanded:integer <- subtract first-index-on-page:integer/space:1 expanded-index:integer/space:1) -;? ($print (("e2\n" literal))) ;? 3 - (x:boolean <- greater-than delta-to-expanded:integer expanded-index:integer/space:1) -;? ($print (("e3\n" literal))) ;? 3 +;? ($print delta-to-expanded:integer) ;? 1 +;? ($print (("\n" literal))) ;? 1 + (x:boolean <- greater-than delta-to-expanded:integer screen-height:integer/space:1) (jump-if x:boolean easy-case:offset) -;? ($print (("f\n" literal))) ;? 4 +;? ($print (("f\n" literal))) ;? 5 ; tough case: expanded index overlaps current and/or previous page (lines-remaining-to-decrement:integer <- copy screen-height:integer/space:1) - ; a) scroll to expanded-index if necessary + ; a) scroll to just below expanded-index if necessary + (below-expanded-index:integer <- add expanded-index:integer/space:1 1:literal) { begin (done?:boolean <- done-scrolling-up default-space:space-address) (break-if done?:boolean) - (done?:boolean <- lesser-or-equal first-index-on-page:integer/space:1 expanded-index:integer/space:1) + (done?:boolean <- lesser-or-equal first-index-on-page:integer/space:1 below-expanded-index:integer) (break-if done?:boolean) -;? ($print (("g\n" literal))) ;? 1 +;? ($print (("g\n" literal))) ;? 2 (first-index-on-page:integer/space:1 <- subtract first-index-on-page:integer/space:1 1:literal) (lines-remaining-to-decrement:integer <- subtract lines-remaining-to-decrement:integer 1:literal) (loop) } - ; b) scroll through expanded-children -;? ($print (("h\n" literal))) ;? 1 - (x:boolean <- equal first-index-on-page:integer/space:1 expanded-index:integer/space:1) - (assert x:boolean (("previous-page error 1" literal))) - (first-subindex-on-page:integer <- copy expanded-children:integer/space:1) + { begin +;? ($print (("h\n" literal))) ;? 2 + (x:boolean <- equal first-index-on-page:integer/space:1 below-expanded-index:integer) + (break-unless x:boolean) + (first-index-on-page:integer/space:1 <- copy expanded-index:integer/space:1) + (first-subindex-on-page:integer/space:1 <- subtract expanded-children:integer/space:1 1:literal) + (lines-remaining-to-decrement:integer <- subtract lines-remaining-to-decrement:integer 1:literal) + } + ; b) scroll through expanded-children if necessary { begin (done?:boolean <- done-scrolling-up default-space:space-address) (break-if done?:boolean) (done?:boolean <- less-than first-subindex-on-page:integer/space:1 0:literal) (break-if done?:boolean) -;? ($print (("i\n" literal))) ;? 1 +;? ($print (("i\n" literal))) ;? 2 (first-subindex-on-page:integer/space:1 <- subtract first-subindex-on-page:integer/space:1 1:literal) (lines-remaining-to-decrement:integer <- subtract lines-remaining-to-decrement:integer 1:literal) (loop) } ; c) jump past expanded-index parent if necessary -;? ($print (("j\n" literal))) ;? 1 +;? ($print (("j\n" literal))) ;? 2 { begin (done?:boolean <- done-scrolling-up default-space:space-address) (break-if done?:boolean) -;? ($print (("k\n" literal))) ;? 1 +;? ($print (("k\n" literal))) ;? 2 (first-index-on-page:integer/space:1 <- subtract first-index-on-page:integer/space:1 1:literal) (first-subindex-on-page:integer/space:1 <- copy -2:literal) (lines-remaining-to-decrement:integer <- subtract lines-remaining-to-decrement:integer 1:literal) } ; d) scroll up before expanded-index if necessary -;? ($print (("i\n" literal))) ;? 1 +;? ($print (("l\n" literal))) ;? 2 { begin (done?:boolean <- done-scrolling-up default-space:space-address) (break-if done?:boolean) -;? ($print (("j\n" literal))) ;? 1 +;? ($print (("m\n" literal))) ;? 2 (first-index-on-page:integer/space:1 <- subtract first-index-on-page:integer/space:1 1:literal) (lines-remaining-to-decrement:integer <- subtract lines-remaining-to-decrement:integer 1:literal) (loop) |