drop the blocks around case bodies, and size block codes by type

A case body that declares is its own block now (sex#51), and sizeof
takes a pointer type (sex#52).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 18:12:51 +03:00
parent 7cb49f83cd
commit 3ff6dcaa74

View File

@@ -79,21 +79,17 @@
(switch type (switch type
(case 1 (snprintf value 64 "%d" (cast (read-le (& r) 4) i32)) (break)) (case 1 (snprintf value 64 "%d" (cast (read-le (& r) 4) i32)) (break))
(case 2 (snprintf value 64 "%lld" (cast (read-le (& r) 8) i64)) (break)) (case 2 (snprintf value 64 "%lld" (cast (read-le (& r) 8) i64)) (break))
;; TODO sex#51: drop the (do ...) around case bodies once each
;; case gets its own scope.
(case 3 (case 3
(do (var bits u64 (read-le (& r) 8))
(var bits u64 (read-le (& r) 8)) (var d double)
(var d double) (memcpy (& d) (& bits) 8)
(memcpy (& d) (& bits) 8) (snprintf value 64 "%.17g" d)
(snprintf value 64 "%.17g" d))
(break)) (break))
(case 4 (case 4
(do (var bits u32 (cast (read-le (& r) 4) u32))
(var bits u32 (cast (read-le (& r) 4) u32)) (var f float)
(var f float) (memcpy (& f) (& bits) 4)
(memcpy (& f) (& bits) 4) (snprintf value 64 "%.9g" (cast f double))
(snprintf value 64 "%.9g" (cast f double)))
(break)) (break))
(case 5 (case 5
(add-config s key (read-dotnet-string (& r))) (add-config s key (read-dotnet-string (& r)))
@@ -128,9 +124,7 @@
(if (> id max-id) (= max-id id))) (if (> id max-id) (= max-id id)))
(.skip (& entry) wire)))) (.skip (& entry) wire))))
(= (. s block-count) (+ max-id 1)) (= (. s block-count) (+ max-id 1))
;; TODO sex#52: write (sizeof (* char)) once sizeof takes a pointer (= (. s block-codes) (calloc (+ max-id 1) (sizeof (* char))))
;; type.
(= (. s block-codes) (calloc (+ max-id 1) (sizeof [(. s block-codes) 0])))
(while (> (.field (& r) (& wire)) 0) (while (> (.field (& r) (& wire)) 0)
(var entry pb (.bytes (& r))) (var entry pb (.bytes (& r)))
(var id int -1) (var id int -1)