The script is in tools/ rather than thrown away, because two lanes are
writing Flan in the old spelling right now and their files need the same
pass at merge.
It works on forms, not on text: a keyword becomes a dot only where it sits
in a field-label position inside a brace, so an enum member in value
position, a map key inside an EDN string and a type-position {K V} are all
left alone. :keys keeps its colon -- it names no field.
26 lines
918 B
Plaintext
26 lines
918 B
Plaintext
;;;; debug.flan with the fields of Cell in a different order and nothing else
|
|
;;;; changed. The program prints the same four lines; the struct is a different
|
|
;;;; shape, and every member sits at a different offset.
|
|
;;;;
|
|
;;;; name at 0 (16), id at 16, alive at 20, 3 of padding, heat at 24 — so a
|
|
;;;; DWARF offset table that is right for debug.flan is wrong for all four
|
|
;;;; members here, which is what makes the pair a test rather than an
|
|
;;;; observation.
|
|
|
|
(defstruct Cell [name string id i32 alive bool heat f64])
|
|
|
|
(defn tick [c (Ptr Cell) n i32] i32
|
|
(let [bump (+ n 1)]
|
|
(set (.heat c) (+ (.heat c) 1.5))
|
|
(set (.id c) bump)
|
|
bump))
|
|
|
|
(defn main [] i32
|
|
(let [c (Cell {.alive true .heat 3.25 .id 7 .name "grain"})]
|
|
(let [r (tick (addr c) 41)]
|
|
(print r) (println "")
|
|
(print (.heat c)) (println "")
|
|
(print (.id c)) (println "")
|
|
(print (.name c)) (println "")
|
|
0)))
|