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