diff options
-rw-r--r-- | trace.arc.t | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/trace.arc.t b/trace.arc.t index dbf2277f..bf81f3f9 100644 --- a/trace.arc.t +++ b/trace.arc.t @@ -255,3 +255,75 @@ schedule: done with routine") (prn "F - process-key doesn't move below bounds")) (reset) +(new-trace "process-key-expand") +(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) + (1:instruction-trace-address-array-address/raw <- parse-traces s:stream-address) + (len:integer <- length 1:instruction-trace-address-array-address/raw/deref) + (2:terminal-address/raw <- init-fake-terminal 70:literal 15:literal) + ; position the cursor away from top of screen + (cursor-down 2:terminal-address/raw) + (cursor-down 2:terminal-address/raw) + (3:space-address/raw <- screen-state) + ; draw trace + (print-traces-collapsed 3:space-address/raw/screen-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset) + ]))) +(run 'main) +(each routine completed-routines* + (awhen rep.routine!error + (prn "error - " it))) +(when (~memory-contains-array memory*.4 + (+ " " + " " + "+ 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 - process-key: before expand")) +(run-code main2 + (default-space:space-address <- new space:literal 30:literal/capacity) + ; move cursor to final line and expand + (s:string-address <- new "k\n") + (k:keyboard-address <- init-keyboard s:string-address) + (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + (process-key 3:space-address/raw/screen-state k:keyboard-address 2:terminal-address/raw 1:instruction-trace-address-array-address/raw) + ) +; final line is expanded +(when (~memory-contains-array memory*.4 + (+ " " + " " + "+ 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)) " + " mem : ((1 integer)): 1 <= 1 " + " mem : ((2 integer)): 2 <= 3 " + " mem : ((1 integer)) => 1 " + " mem : ((2 integer)) => 3 " + " mem : ((3 integer)): 3 <= 4 " + " schedule : done with routine ")) + (prn "F - process-key expands current trace segment on <enter>")) + +(reset) |