about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-01 17:09:06 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-03-01 20:29:43 -0800
commit475882576c296941722b7b630825046ef79de36c (patch)
tree9520f4967d6e18de4932e0db7c264f9775982569
parent596709d3022ba8e2e2d60547dd8b1f66b5ffc43f (diff)
downloadmu-475882576c296941722b7b630825046ef79de36c.tar.gz
856 - stop perturbing traces on new functions
Still hacky, but now we can standardize the couple of different
workflows we need.
-rw-r--r--chessboard.arc.t250
-rw-r--r--mu.arc24
-rw-r--r--trace.arc.t283
3 files changed, 267 insertions, 290 deletions
diff --git a/chessboard.arc.t b/chessboard.arc.t
index 14c649f0..c5698f00 100644
--- a/chessboard.arc.t
+++ b/chessboard.arc.t
@@ -1,38 +1,35 @@
 (selective-load "mu.arc" section-level)
 (set allow-raw-addresses*)
+(add-code:readfile "chessboard.mu")
+(freeze function*)
+(load-system-functions)
 
-(reset)
+(reset2)
 (new-trace "read-move-legal")
-(add-code:readfile "chessboard.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (stdin:channel-address <- init-channel 1:literal)
-      (r:integer/routine <- fork read-move:fn nil:literal/globals 2000:literal/limit stdin:channel-address)
-      (c:character <- copy ((#\a literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (c:character <- copy ((#\2 literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (c:character <- copy ((#\- literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (c:character <- copy ((#\a literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (c:character <- copy ((#\4 literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (c:character <- copy ((#\newline literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (sleep until-routine-done:literal r:integer/routine)
-     ])))
-;? (set dump-trace*)
-;? (= dump-trace* (obj whitelist '("schedule")))
-;? (= dump-trace* (obj whitelist '("schedule" "run")))
-(run 'main)
+(run-code main
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (stdin:channel-address <- init-channel 1:literal)
+  (r:integer/routine <- fork read-move:fn nil:literal/globals 2000:literal/limit stdin:channel-address)
+  (c:character <- copy ((#\a literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (c:character <- copy ((#\2 literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (c:character <- copy ((#\- literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (c:character <- copy ((#\a literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (c:character <- copy ((#\4 literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (c:character <- copy ((#\newline literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (sleep until-routine-done:literal r:integer/routine)
+)
 (each routine completed-routines*
 ;?   (prn "  " routine)
   (awhen rep.routine!error
@@ -43,13 +40,10 @@
 ; but that's at a lower level
 ;? (quit)
 
-(reset)
+(reset2)
 (new-trace "read-move-incomplete")
-(add-code:readfile "chessboard.mu")
 ; initialize some variables at specific raw locations
 ;? (prn "== init")
-(freeze function*)
-(load-system-functions)
 (run-code test-init
   (1:channel-address/raw <- init-channel 1:literal)
   (2:terminal-address/raw <- init-fake-terminal 20:literal 10:literal)
@@ -105,40 +99,33 @@
     (prn "F - 'read-move' completes after final letter of move"))
 )
 
-(reset)
+(reset2)
 (new-trace "read-move-quit")
-(add-code:readfile "chessboard.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (stdin:channel-address <- init-channel 1:literal)
-      (dummy:terminal-address <- init-fake-terminal 20:literal 10:literal)
-      (r:integer/routine <- fork-helper read-move:fn nil:literal/globals 2000:literal/limit stdin:channel-address dummy:terminal-address)
-      (c:character <- copy ((#\q literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (sleep until-routine-done:literal r:integer/routine)
-     ])))
-(run 'main)
+(run-code main
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (stdin:channel-address <- init-channel 1:literal)
+  (dummy:terminal-address <- init-fake-terminal 20:literal 10:literal)
+  (r:integer/routine <- fork-helper read-move:fn nil:literal/globals 2000:literal/limit stdin:channel-address dummy:terminal-address)
+  (c:character <- copy ((#\q literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (sleep until-routine-done:literal r:integer/routine)
+)
 (when (~ran-to-completion 'read-move)
   (prn "F - chessboard quits on move starting with 'q'"))
 
-(reset)
+(reset2)
 (new-trace "read-illegal-file")
-(add-code:readfile "chessboard.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (stdin:channel-address <- init-channel 1:literal)
-      (dummy:terminal-address <- init-fake-terminal 20:literal 10:literal)
-      (r:integer/routine <- fork-helper read-file:fn nil:literal/globals 2000:literal/limit stdin:channel-address dummy:terminal-address)
-      (c:character <- copy ((#\i literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (sleep until-routine-done:literal r:integer/routine)
-     ])))
-;? (= dump-trace* (obj whitelist '("schedule")))
-(run 'main)
+(run-code main
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (stdin:channel-address <- init-channel 1:literal)
+  (dummy:terminal-address <- init-fake-terminal 20:literal 10:literal)
+  (r:integer/routine <- fork-helper read-file:fn nil:literal/globals 2000:literal/limit stdin:channel-address dummy:terminal-address)
+  (c:character <- copy ((#\i literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (sleep until-routine-done:literal r:integer/routine)
+)
 ;? (each routine completed-routines*
 ;?   (prn "  " routine))
 (when (or (ran-to-completion 'read-file)
@@ -146,48 +133,40 @@
             (~posmatch "file too high" rep.routine!error)))
   (prn "F - 'read-file' checks that file lies between 'a' and 'h'"))
 
-(reset)
+(reset2)
 (new-trace "read-illegal-rank")
-(add-code:readfile "chessboard.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (stdin:channel-address <- init-channel 1:literal)
-      (dummy:terminal-address <- init-fake-terminal 20:literal 10:literal)
-      (r:integer/routine <- fork-helper read-rank:fn nil:literal/globals 2000:literal/limit stdin:channel-address dummy:terminal-address)
-      (c:character <- copy ((#\9 literal)))
-      (x:tagged-value <- save-type c:character)
-      (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
-      (sleep until-routine-done:literal r:integer/routine)
-     ])))
-(run 'main)
+(run-code main
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (stdin:channel-address <- init-channel 1:literal)
+  (dummy:terminal-address <- init-fake-terminal 20:literal 10:literal)
+  (r:integer/routine <- fork-helper read-rank:fn nil:literal/globals 2000:literal/limit stdin:channel-address dummy:terminal-address)
+  (c:character <- copy ((#\9 literal)))
+  (x:tagged-value <- save-type c:character)
+  (stdin:channel-address/deref <- write stdin:channel-address x:tagged-value)
+  (sleep until-routine-done:literal r:integer/routine)
+)
 (when (or (ran-to-completion 'read-rank)
           (let routine routine-running!read-rank
             (~posmatch "rank too high" rep.routine!error)))
   (prn "F - 'read-rank' checks that rank lies between '1' and '8'"))
 
-(reset)
+(reset2)
 (new-trace "print-board")
-(add-code:readfile "chessboard.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (initial-position:list-address <- init-list ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal))
-                                                  ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
-                                                  ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
-                                                  ((#\Q literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\q literal))
-                                                  ((#\K literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\k literal))
-                                                  ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
-                                                  ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
-                                                  ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal)))
-      (b:board-address <- init-board initial-position:list-address)
-      (screen:terminal-address <- init-fake-terminal 20:literal 10:literal)
-      (print-board screen:terminal-address b:board-address)
-      (1:string-address/raw <- get screen:terminal-address/deref data:offset)
-     ])))
-;? (set dump-trace*)
-;? (= dump-trace* (obj whitelist '("run")))
-(run 'main)
+(run-code main
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  (initial-position:list-address <- init-list ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal))
+                                              ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
+                                              ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
+                                              ((#\Q literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\q literal))
+                                              ((#\K literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\k literal))
+                                              ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
+                                              ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
+                                              ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal)))
+  (b:board-address <- init-board initial-position:list-address)
+  (screen:terminal-address <- init-fake-terminal 20:literal 10:literal)
+  (print-board screen:terminal-address b:board-address)
+  (1:string-address/raw <- get screen:terminal-address/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -206,45 +185,40 @@
   (prn "F - print-board works; chessboard begins at @memory*.1"))
 
 ; todo: how to fold this more elegantly with the previous test?
-(reset)
+(reset2)
 (new-trace "make-move")
-(add-code:readfile "chessboard.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      ; hook up stdin
-      (stdin:channel-address <- init-channel 1:literal)
-      ; fake screen
-      (screen:terminal-address <- init-fake-terminal 20:literal 10:literal)
-      ; initial position
-      (initial-position:list-address <- init-list ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal))
-                                                  ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
-                                                  ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
-                                                  ((#\Q literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\q literal))
-                                                  ((#\K literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\k literal))
-                                                  ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
-                                                  ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
-                                                  ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal)))
-      (b:board-address <- init-board initial-position:list-address)
-      ; move: a2-a4
-      (m:move-address <- new move:literal)
-      (f:integer-integer-pair-address <- get-address m:move-address/deref from:offset)
-      (dest:integer-address <- get-address f:integer-integer-pair-address/deref 0:offset)
-      (dest:integer-address/deref <- copy 0:literal)  ; from-file: a
-      (dest:integer-address <- get-address f:integer-integer-pair-address/deref 1:offset)
-      (dest:integer-address/deref <- copy 1:literal)  ; from-rank: 2
-      (t0:integer-integer-pair-address <- get-address m:move-address/deref to:offset)
-      (dest:integer-address <- get-address t0:integer-integer-pair-address/deref 0:offset)
-      (dest:integer-address/deref <- copy 0:literal)  ; to-file: a
-      (dest:integer-address <- get-address t0:integer-integer-pair-address/deref 1:offset)
-      (dest:integer-address/deref <- copy 3:literal)  ; to-rank: 4
-      (b:board-address <- make-move b:board-address m:move-address)
-      (print-board screen:terminal-address b:board-address)
-      (1:string-address/raw <- get screen:terminal-address/deref data:offset)
-     ])))
-;? (set dump-trace*)
-;? (= dump-trace* (obj whitelist '("run")))
-(run 'main)
+(run-code main
+  (default-space:space-address <- new space:literal 30:literal/capacity)
+  ; hook up stdin
+  (stdin:channel-address <- init-channel 1:literal)
+  ; fake screen
+  (screen:terminal-address <- init-fake-terminal 20:literal 10:literal)
+  ; initial position
+  (initial-position:list-address <- init-list ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal))
+                                              ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
+                                              ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
+                                              ((#\Q literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\q literal))
+                                              ((#\K literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\k literal))
+                                              ((#\B literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\b literal))
+                                              ((#\N literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\n literal))
+                                              ((#\R literal)) ((#\P literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\_ literal)) ((#\p literal)) ((#\r literal)))
+  (b:board-address <- init-board initial-position:list-address)
+  ; move: a2-a4
+  (m:move-address <- new move:literal)
+  (f:integer-integer-pair-address <- get-address m:move-address/deref from:offset)
+  (dest:integer-address <- get-address f:integer-integer-pair-address/deref 0:offset)
+  (dest:integer-address/deref <- copy 0:literal)  ; from-file: a
+  (dest:integer-address <- get-address f:integer-integer-pair-address/deref 1:offset)
+  (dest:integer-address/deref <- copy 1:literal)  ; from-rank: 2
+  (t0:integer-integer-pair-address <- get-address m:move-address/deref to:offset)
+  (dest:integer-address <- get-address t0:integer-integer-pair-address/deref 0:offset)
+  (dest:integer-address/deref <- copy 0:literal)  ; to-file: a
+  (dest:integer-address <- get-address t0:integer-integer-pair-address/deref 1:offset)
+  (dest:integer-address/deref <- copy 3:literal)  ; to-rank: 4
+  (b:board-address <- make-move b:board-address m:move-address)
+  (print-board screen:terminal-address b:board-address)
+  (1:string-address/raw <- get screen:terminal-address/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -262,4 +236,4 @@
              "    a b c d e f g h "))
   (prn "F - make-move works; chessboard begins at @memory*.1"))
 
-(reset)
+(reset2)
diff --git a/mu.arc b/mu.arc
index 01f2586f..c748722f 100644
--- a/mu.arc
+++ b/mu.arc
@@ -36,6 +36,29 @@
   (each f (as cons initialization-fns*)
     (f)))
 
+; kludge to prevent reloading functions in .mu files for every test
+(def reset2 ()
+  (= memory* (table))
+  (= Memory-allocated-until 1000)
+  (awhen curr-trace-file*
+    (tofile (+ trace-dir* it)
+      (each (label trace) (as cons traces*)
+        (pr label ": " trace))))
+  (= curr-trace-file* nil)
+  (= traces* (queue))
+  (wipe dump-trace*)
+  (wipe function*!main)
+  (wipe location*!main)
+  (= running-routines* (queue))
+  (= sleeping-routines* (table))
+  (wipe completed-routines*)
+  (wipe routine*)
+  (= abort-routine* (parameter nil))
+  (= curr-cycle* 0)
+  (= scheduling-interval* 500)
+  (= scheduler-switch-table* nil)
+  )
+
 (mac on-init body
   `(enq (fn () ,@body)
         initialization-fns*))
@@ -1728,6 +1751,7 @@
      (wipe (function* ',name))
      (add-code '((function ,name [ ,@body ])))
      (freeze-another ',name)
+;?      (set dump-trace*) ;? 1
      (run-more ',name)))
 
 (def routine-that-ran (f)
diff --git a/trace.arc.t b/trace.arc.t
index d58a8aa6..dd815b87 100644
--- a/trace.arc.t
+++ b/trace.arc.t
@@ -1,13 +1,14 @@
 (selective-load "mu.arc" section-level)
 (set allow-raw-addresses*)
+(add-code:readfile "trace.mu")
+(freeze function*)
+(load-system-functions)
 
-(reset)
+(reset2)
 (new-trace "print-trace")
-(add-code:readfile "trace.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (x:string-address <- new
+(run-code 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))
@@ -21,17 +22,14 @@ 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)
-      (browser-state:space-address <- browser-state traces:instruction-trace-address-array-address 30:literal/screen-height)
-      (print-traces-collapsed browser-state:space-address screen:terminal-address)
-      (1:string-address/raw <- get screen:terminal-address/deref data:offset)
-    ])))
-;? (set dump-trace*)
-;? (= dump-trace* (obj whitelist '("run")))
-(run 'main)
+  (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)
+  (browser-state:space-address <- browser-state traces:instruction-trace-address-array-address 30:literal/screen-height)
+  (print-traces-collapsed browser-state:space-address screen:terminal-address)
+  (1:string-address/raw <- get screen:terminal-address/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -46,13 +44,11 @@ schedule:  done with routine")
   (prn "F - print-traces-collapsed works"))
 ;? (quit) ;? 1
 
-(reset)
+(reset2)
 (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
+(run-code 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))
@@ -66,18 +62,17 @@ 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)
-      (1:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
-      ; position the cursor away from top of screen
-      (cursor-down 1:terminal-address/raw)
-      (cursor-down 1:terminal-address/raw)
-      (browser-state:space-address <- browser-state traces:instruction-trace-address-array-address 30:literal/screen-height)
-      (print-traces-collapsed browser-state:space-address 1:terminal-address/raw traces:instruction-trace-address-array-address)
-      (2:string-address/raw <- get 1:terminal-address/raw/deref data:offset)
-    ])))
-(run 'main)
+  (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)
+  (1:terminal-address/raw <- init-fake-terminal 70:literal 15:literal)
+  ; position the cursor away from top of screen
+  (cursor-down 1:terminal-address/raw)
+  (cursor-down 1:terminal-address/raw)
+  (browser-state:space-address <- browser-state traces:instruction-trace-address-array-address 30:literal/screen-height)
+  (print-traces-collapsed browser-state:space-address 1:terminal-address/raw traces:instruction-trace-address-array-address)
+  (2:string-address/raw <- get 1:terminal-address/raw/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -105,13 +100,11 @@ schedule:  done with routine")
             "*                                                                     "))
   (prn "F - print-traces-collapsed leaves cursor at next line"))
 
-(reset)
+(reset2)
 (new-trace "process-key-move-up-down")
-(add-code:readfile "trace.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (x:string-address <- new
+(run-code 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))
@@ -125,26 +118,25 @@ 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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
-      ; draw trace
-      (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
-      ; move cursor up
-      ; we have no way yet to test special keys like up-arrow
-      (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)
-      ; draw cursor
-      (replace-character 2:terminal-address/raw ((#\* literal)))
-      (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
-    ])))
-(run 'main)
+  (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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
+  ; draw trace
+  (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
+  ; move cursor up
+  ; we have no way yet to test special keys like up-arrow
+  (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)
+  ; draw cursor
+  (replace-character 2:terminal-address/raw ((#\* literal)))
+  (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -161,7 +153,7 @@ schedule:  done with routine")
   (prn "F - process-key can move up"))
 (run-code main2
   (default-space:space-address <- new space:literal 30:literal/capacity)
-  ; reset previous cursor
+  ; reset2 previous cursor
   (replace-character 2:terminal-address/raw ((#\+ literal)))
   ; move cursor up 3 more lines
   (s:string-address <- new "kkk")
@@ -254,13 +246,11 @@ schedule:  done with routine")
             "*                                                                     "))
   (prn "F - process-key doesn't move below bounds"))
 
-(reset)
+(reset2)
 (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
+(run-code 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))
@@ -274,19 +264,18 @@ 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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
-      ; draw trace
-      (print-traces-collapsed 3:space-address/raw/browser-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)
+  (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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
+  ; draw trace
+  (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
+  (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -339,13 +328,11 @@ schedule:  done with routine")
             "   schedule :  done with routine                                      "))
   (prn "F - process-key positions cursor on top of trace after expanding"))
 
-(reset)
+(reset2)
 (new-trace "process-key-expand-nonlast")
-(add-code:readfile "trace.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (x:string-address <- new
+(run-code 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))
@@ -359,25 +346,24 @@ 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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
-      ; draw trace
-      (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
-      ; expand penultimate line
-      (s:string-address <- new "kk\n")
-      (k:keyboard-address <- init-keyboard s:string-address)
-      (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
-      (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
-      (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
-      (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
-    ])))
-(run 'main)
+  (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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
+  ; draw trace
+  (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
+  ; expand penultimate line
+  (s:string-address <- new "kk\n")
+  (k:keyboard-address <- init-keyboard s:string-address)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -394,13 +380,11 @@ schedule:  done with routine")
             "+ main/ 2 : 4 => ((3 integer))                                        "))
   (prn "F - process-key: expanding a line continues to print lines after it"))
 
-(reset)
+(reset2)
 (new-trace "process-key-expanded")
-(add-code:readfile "trace.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (x:string-address <- new
+(run-code 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))
@@ -415,28 +399,26 @@ 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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
-      ; draw trace
-      (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
-      ; expand penultimate line, then move one line down and draw cursor
-      (s:string-address <- new "kk\nj")
-      (k:keyboard-address <- init-keyboard s:string-address)
-      (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
-      (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
-      (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
-      (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
-      (replace-character 2:terminal-address/raw ((#\* literal)))
-      (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
-    ])))
-;? (set dump-trace*) ;? 1
-(run 'main)
+  (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 <- browser-state 1:instruction-trace-address-array-address/raw 30:literal/screen-height)
+  ; draw trace
+  (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw 1:instruction-trace-address-array-address/raw)
+  ; expand penultimate line, then move one line down and draw cursor
+  (s:string-address <- new "kk\nj")
+  (k:keyboard-address <- init-keyboard s:string-address)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (process-key 3:space-address/raw/browser-state k:keyboard-address 2:terminal-address/raw)
+  (replace-character 2:terminal-address/raw ((#\* literal)))
+  (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -455,7 +437,7 @@ schedule:  done with routine")
   (prn "F - process-key: navigation moves between top-level lines only"))
 (run-code main2
   (default-space:space-address <- new space:literal 30:literal/capacity)
-  ; reset previous cursor
+  ; reset2 previous cursor
   (replace-character 2:terminal-address/raw ((#\+ literal)))
   ; move cursor back up one line
   (s:string-address <- new "k")
@@ -482,7 +464,7 @@ schedule:  done with routine")
   (prn "F - process-key: navigation moves between top-level lines only"))
 (run-code main3
   (default-space:space-address <- new space:literal 30:literal/capacity)
-  ; reset previous cursor
+  ; reset2 previous cursor
   (replace-character 2:terminal-address/raw ((#\+ literal)))
   ; press enter
   (s:string-address <- new "\n")
@@ -539,13 +521,11 @@ schedule:  done with routine")
 
 ;; manage screen height
 
-(reset)
+(reset2)
 (new-trace "trace-paginate")
-(add-code:readfile "trace.mu")
-(add-code
-  '((function! main [
-      (default-space:space-address <- new space:literal 30:literal/capacity)
-      (x:string-address <- new
+(run-code main
+  (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
@@ -561,15 +541,14 @@ 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)
-      (len:integer <- length traces:instruction-trace-address-array-address/deref)
-      (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)
-      (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw)
-      (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
-    ])))
-(run 'main)
+  (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)
+  (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)
+  (print-traces-collapsed 3:space-address/raw/browser-state 2:terminal-address/raw)
+  (4:string-address/raw <- get 2:terminal-address/raw/deref data:offset)
+)
 (each routine completed-routines*
   (awhen rep.routine!error
     (prn "error - " it)))
@@ -750,5 +729,5 @@ run: main 7: n")
             "                 "))
   (prn "F - page up understands expanded lines"))
 
-(reset)
+(reset2)
 ;? (print-times) ;? 3