27 lines
1.2 KiB
Plaintext
27 lines
1.2 KiB
Plaintext
;;;; The indirection cell, from the outside.
|
|
;;;;
|
|
;;;; Nothing in the corpus can tell a build with cells from one without: a dev
|
|
;;;; build starts with every cell pointing at the body this build compiled, so
|
|
;;;; it prints what a release build prints, which is exactly the property that
|
|
;;;; makes the whole corpus a safe test of the cells and a useless test of
|
|
;;;; whether anything actually reads one.
|
|
;;;;
|
|
;;;; test/cells.sh is what reads one. It preloads a shared object whose
|
|
;;;; constructor looks up flan.cell.twice by name and stores a different body
|
|
;;;; into it, so a build that routes through the cell prints the new body's
|
|
;;;; answer and a build that calls the symbol prints the old one. Run against
|
|
;;;; the LLVM dev build and the x86 dev build, the two must agree; run against
|
|
;;;; a release build of either, nothing must change.
|
|
;;;;
|
|
;;;; Two call shapes, because they are two different cases in both backends:
|
|
;;;; a direct call by name, and a function *value* — Tast.FnAddr (Fnval _),
|
|
;;;; which is the one FnAddr that is not the symbol.
|
|
|
|
(defn twice [n i64] i64 (* n 2))
|
|
|
|
(defn apply1 [f (Fn [i64] i64) n i64] i64 (f n))
|
|
|
|
(defn main [] ()
|
|
(println (twice 21)) ; direct call
|
|
(println (apply1 twice 21))) ; through the value, taken here
|