fix four conditional operands sexc emitted without parentheses, and mark every Sex workaround with a TODO

A conditional as an operand loses its parentheses (sex#59): box-blur
allocated a quarter of its buffer, deep water got the shallow colour,
and verify's delta histogram wrote out of bounds into the height
classes. Plan.org quoted the corrupted count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 21:01:59 +03:00
parent 39b0e74f2b
commit c14c154303
22 changed files with 156 additions and 5 deletions

View File

@@ -10,6 +10,9 @@
;;; certainly air above.
(include stdio.h stdlib.h string.h math.h)
;; TODO sex#58: import only the modules used here once an import brings
;; the types its interface needs; until then, every dependency, in
;; dependency order.
(import maps)
(import lcg)
(import noise)
@@ -21,6 +24,8 @@
;;; NewSimplexNoiseLayer --------------------------------------------
;; TODO sex#47: write these in hex, as the C# does, once there are hex
;; literals.
(define PRIME-X 5910200641878280303)
(define PRIME-Y 6452764530575939509)
(define PRIME-Z 6614699811220273867)
@@ -140,6 +145,8 @@
(var xf1 float (- (* (cast (- -2 (* xn 4)) float) x1) one))
(var yf1 float (- (* (cast (- -2 (* yn 4)) float) y1) one))
(var zf1 float (- (* (cast (- -2 (* zn 4)) float) z1) one))
;; TODO sex#62: cast (c-bit-or xn 1) to float directly once a cast of
;; a bitwise expression keeps its parentheses.
(var xsi int (c-bit-or xn 1))
(var ysi int (c-bit-or yn 1))
(var zsi int (c-bit-or zn 1))
@@ -278,6 +285,7 @@
;;; *tanh* curve. GenTerra turns its threshold into a noise value with
;;; this one, though the column bounds use the new noise's own curve.
(fn tanh-curve-inverse ((v double)) double
;; TODO sex#63: write -INFINITY once it reads as a negation.
(if (<= v 0.0) (return (- INFINITY)))
(if (>= v 1.0) (return INFINITY))
(return (* 0.5 (log (/ v (- 1.0 v))))))
@@ -672,6 +680,8 @@
(var oct-a [double 64])
(var oct-t [double 64])
(for (var k int 0) (< k 4) (++ k)
;; TODO sex#59: put the (if ...)s in the sums below once a
;; conditional operand keeps its parentheses.
(var ox float (if (& k 1) pixel 0))
(var oz float (if (& k 2) pixel 0))
(landform-weights/at (& (. t weights)) (+ base-x ox) (+ base-z oz) w n)