def room

bend-kit-bits@0.1.0.1 · bits.bend:118

import bend-kit-bits@0.1.0.1/bits.bend as Bits
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

118# A write adds at most 32 bits, so one doubling always makes room.
119def room(full: Bool, w: Writer) -> Writer:
120  match full:
121    case False{}:
122      w
123    case True{}:
124      Writer{buf, +dep, pos} = w
125      Writer{Bytes.dst(Bytes.copy(U32.shln(4, U32.to_nat(dep)), buf, Array.new(U32, U32.to_nat((dep + 1 : U32)), 0), 0, 0)), (dep + 1 : U32), pos}

Uses (9)

Used by (1)