def pk.enc.pick

bend-osdev-acpi@0.1.1.0 · aml_pkglength.bend:32

import bend-osdev-acpi@0.1.1.0/aml_pkglength.bend as AmlPkglength
import Base

32def pk.enc.pick(s1: Bool, s2: Bool, s3: Bool, +v: U32) -> List<&2, U32>:
33  match s1:
34    case True{}:
35      [U32.and(63, v)]
36    case False{}:
37      match s2:
38        case True{}:
39          [U32.or(64, U32.and(15, v)), U32.and(255, U32.shrn(v, 4n))]
40        case False{}:
41          match s3:
42            case True{}:
43              [U32.or(128, U32.and(15, v)), U32.and(255, U32.shrn(v, 4n)), U32.and(255, U32.shrn(v, 12n))]
44            case False{}:
45              [U32.or(192, U32.and(15, v)), U32.and(255, U32.shrn(v, 4n)), U32.and(255, U32.shrn(v, 12n)), U32.and(255, U32.shrn(v, 20n))]

Uses (6)

Used by (1)