diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-10 22:53:29 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-10 22:53:29 -0800 |
commit | e25036038374f6879db794ad2086711521311e97 (patch) | |
tree | 3a911159ad16b2bd5e44af8eef77112dd563499d | |
parent | 285e0963a711da019f0ea27c234b19d3c76b5ee5 (diff) | |
download | mu-e25036038374f6879db794ad2086711521311e97.tar.gz |
740
-rw-r--r-- | mu.arc | 12 | ||||
-rw-r--r-- | trace.arc.t | 50 |
2 files changed, 58 insertions, 4 deletions
diff --git a/mu.arc b/mu.arc index 9286cede..9590f561 100644 --- a/mu.arc +++ b/mu.arc @@ -1649,13 +1649,13 @@ (and (>= memory*.addr len.value) (loop (addr (+ addr 1) idx 0) -;? (and (< idx len.value) (prn "comparing @idx: @memory*.addr and @value.idx")) ;? 1 +;? (and (< idx len.value) (prn "comparing @idx: @memory*.addr and @value.idx")) ;? 2 (if (>= idx len.value) t (~is memory*.addr value.idx) (do1 nil (prn "@addr should contain @(repr value.idx) but contains @(repr memory*.addr)") -;? (recur (+ addr 1) (+ idx 1)) ;? 4 +;? (recur (+ addr 1) (+ idx 1)) ;? 5 ) :else (recur (+ addr 1) (+ idx 1)))))) @@ -2585,14 +2585,19 @@ (init-fn cursor-down (default-space:space-address <- new space:literal 30:literal) (x:terminal-address <- next-input) +;? ($print ((#\# literal))) ;? 1 (height:integer-address <- get-address x:terminal-address/deref num-rows:offset) +;? ($print height:integer-address/deref) ;? 1 { begin (break-unless x:terminal-address) +;? ($print ((#\% literal))) ;? 1 (row:integer-address <- get-address x:terminal-address/deref cursor-row:offset) { begin - (bottom?:boolean <- lesser-or-equal row:integer-address/deref height:integer-address/deref) + (bottom?:boolean <- greater-or-equal row:integer-address/deref height:integer-address/deref) (break-if bottom?:boolean) (row:integer-address/deref <- add row:integer-address/deref 1:literal) +;? ($print ((#\* literal))) ;? 1 +;? ($print row:integer-address/deref) ;? 1 } (reply) } @@ -2628,6 +2633,7 @@ { begin (break-unless x:terminal-address) (row:integer-address <- get-address x:terminal-address/deref cursor-row:offset) +;? ($print row:integer-address/deref) ;? 1 (col:integer-address <- get-address x:terminal-address/deref cursor-col:offset) (width:integer <- get x:terminal-address/deref num-cols:offset) (t1:integer <- multiply row:integer-address/deref width:integer) diff --git a/trace.arc.t b/trace.arc.t index 2e7faa93..e8f561cd 100644 --- a/trace.arc.t +++ b/trace.arc.t @@ -24,7 +24,6 @@ schedule: done with routine") (s:stream-address <- init-stream x:string-address) (traces:instruction-trace-address-array-address <- parse-traces s:stream-address) (len:integer <- length traces:instruction-trace-address-array-address/deref) - ; fake screen (screen:terminal-address <- init-fake-terminal 70:literal 15:literal) (screen-state:space-address <- screen-state) (print-traces-collapsed screen-state:space-address screen:terminal-address traces:instruction-trace-address-array-address) @@ -47,3 +46,52 @@ schedule: done with routine") (prn "F - print-traces-collapsed works")) (reset) +(new-trace "print-trace-from-middle-of-screen") +(add-code:readfile "trace.mu") +(add-code + '((function! main [ + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:string-address <- new +"schedule: main +run: main 0: (((1 integer)) <- ((copy)) ((1 literal))) +run: main 0: 1 => ((1 integer)) +mem: ((1 integer)): 1 <= 1 +run: main 1: (((2 integer)) <- ((copy)) ((3 literal))) +run: main 1: 3 => ((2 integer)) +mem: ((2 integer)): 2 <= 3 +run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) +mem: ((1 integer)) => 1 +mem: ((2 integer)) => 3 +run: main 2: 4 => ((3 integer)) +mem: ((3 integer)): 3 <= 4 +schedule: done with routine") + (s:stream-address <- init-stream x:string-address) + (traces:instruction-trace-address-array-address <- parse-traces s:stream-address) + (len:integer <- length traces:instruction-trace-address-array-address/deref) + (screen:terminal-address <- init-fake-terminal 70:literal 15:literal) + ; position the cursor away from top of screen + (cursor-down screen:terminal-address) + (cursor-down screen:terminal-address) + (screen-state:space-address <- screen-state) + (print-traces-collapsed screen-state:space-address screen:terminal-address traces:instruction-trace-address-array-address) + (1:string-address/raw <- get screen:terminal-address/deref data:offset) + ]))) +;? (set dump-trace*) +;? (= dump-trace* (obj whitelist '("run"))) +(run 'main) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +;? (prn memory*.1) +(when (~memory-contains-array memory*.1 + (+ " " + " " + "+ main/ 0 : (((1 integer)) <- ((copy)) ((1 literal))) " + "+ main/ 0 : 1 => ((1 integer)) " + "+ main/ 1 : (((2 integer)) <- ((copy)) ((3 literal))) " + "+ main/ 1 : 3 => ((2 integer)) " + "+ main/ 2 : (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) " + "+ main/ 2 : 4 => ((3 integer)) ")) + (prn "F - print-traces-collapsed works")) + +(reset) |