def put

bend-kit-encoding@0.5.0.0 · encoding.bend:12

import bend-kit-encoding@0.5.0.0/encoding.bend as Encoding
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

12# Bytes enter at the top of w, as in Bytes.from_string; every fourth byte stores the word.
13def put(o: Out, +b: U32) -> Out:
14  Out{buf, +n, +w} = o
15  +w2 = ((w >> 8n) .|. (b << 24n) : U32)
16  +full = U32.is_eq((n .&. 3 : U32), 3)
17  Out{Bytes.flush(full, buf, (n >> 2n : U32), w2), (n + 1 : U32), Bool.pick(U32, full, 0, w2)}

Uses (10)

Used by (4)