;;;; One global of every shape the inspector walks, for comparing two ;;;; renderings of each: the break loop's [globals], which reads the stopped ;;;; program's memory through lib/inspect.ml and compiles nothing, and an ;;;; evaluated expression naming the global, which is still rendered by a ;;;; compiled thunk through lib/render.ml. They must agree byte for byte — ;;;; the editor parses both back, and a value that read one way in the break ;;;; buffer and another at C-x C-e would be two answers to one question. (import agent "vendor:agent") (defstruct Boom [why i32]) (defstruct Point [x f32 y f32]) (defstruct Wide [a i32 b i32 c i32 d i32 e i32 f i32 g i32 h i32 i i32 j i32]) (defstruct In4 [v i32]) (defstruct In3 [v In4]) (defstruct In2 [v In3]) (defstruct In1 [v In2]) (defstruct In0 [v In1]) (defstruct Enemy [hp i32 x i32]) (defenum Colour [red 0 green 1 blue 2]) (defdata Shape [Empty (Dot [x f64 y f64]) (Rect [w i32 h i32])]) (defunion W [p (Ptr i32) n u64]) (defstruct Pair [a $t b $t]) (defonce small i8) (defonce mid u16) (defonce large u32) (defonce huge u64) (defonce neg i64) (defonce ratio f32) (defonce far f64) (defonce odd f64) (defonce yes bool) (defonce byte u8) (defonce text string) (defonce colour Colour) (defonce stray Colour) (defonce some (Option Point)) (defonce none (Option i32)) (defonce wide Wide) (defonce deep In0) (defonce dot Shape) (defonce empty Shape) (defonce row [10 i32]) (defonce words [u8]) (defonce nums [i32]) (defonce live (Ptr Enemy)) (defonce dead (Ptr Enemy)) (defonce nowhere (Ptr Enemy)) (defonce un W) (defonce anything dyn) (defonce pair (Pair i32)) ;; The innermost frame names every global above, so the break loop's section ;; holds all of them; then it stops. Each is stored back to itself rather than ;; printed: a frame that prints is refused attribution today (TODO.org, "A ;; frame that prints is skipped from the globals section"), and this is about ;; the values. (defn inner [] i64 (set small small) (set mid mid) (set large large) (set huge huge) (set neg neg) (set ratio ratio) (set far far) (set odd odd) (set yes yes) (set byte byte) (set text text) (set colour colour) (set stray stray) (set some some) (set none none) (set wide wide) (set deep deep) (set dot dot) (set empty empty) (set row row) (set words words) (set nums nums) (set live live) (set dead dead) (set nowhere nowhere) (set un un) (set anything anything) (set pair pair) (error (Boom {.why 3})) 0) (defn main [] i32 (agent/start "/tmp/flan-dev-parity-fallback.sock") (let [v (vec-new Enemy) w (vec-new Enemy) bytes (vec-new u8) ints (vec-new i32)] (push v (Enemy {.hp 41 .x 2})) (push w (Enemy {.hp 7 .x 9})) (push bytes 104) (push bytes 105) (push bytes 10) (push ints 4) (push ints -5) (push ints 6) (set live (addr (at v 0))) (set dead (addr (at w 0))) (free w) (set words (slice bytes)) (set nums (slice ints)) (set small -5) (set mid 65535) (set large 4000000000) (set huge (u64 -1)) (set neg -9000000000) (set ratio 1.25) (set far 3.5e20) (set odd (/ 0.0 0.0)) (set yes true) (set byte 97) (set text "a\"b\\c\nd\te") (set colour :blue) (set some (Some (Point {.x 1.5 .y -2.5}))) (set wide (Wide {.a 1 .b 2 .c 3 .d 4 .e 5 .f 6 .g 7 .h 8 .i 9 .j 10})) (set deep (In0 {.v (In1 {.v (In2 {.v (In3 {.v (In4 {.v 5})})})})})) (set dot (Shape.Dot {.x 0.5 .y 2})) (set empty Shape.Empty) (set (at row 0) 11) (set (at row 9) 99) (set un (W {.n 12})) (set anything {:s "kept" :n 1}) (set pair (Pair 3 4)) (print (inner)) (println "")) (dotimes [i 4000] (agent/wait 5)) 0)