def bpf_decode.go

bend-osdev-bpf@0.1.0.0 · insn.bend:349

import bend-osdev-bpf@0.1.0.0/insn.bend as Insn
import Base

349# a: the instructions before pc, last first, or the first failure; the loop
350# stops at the instruction after a failure
351def bpf_decode.go(rs: List<&2, BpfRaw>, +pc: Nat, a: Result<&2, &2, BpfError, List<&2, BpfOp>>) -> Result<&2, &2, BpfError, List<&2, BpfOp>>:
352  match rs:
353    case Nil{}:
354      match a:
355        case Fail{e}:
356          Fail{e}
357        case Done{acc}:
358          Done{List.reverse(&2, BpfOp, acc)}
359    case Con{+r, t}:
360      match a:
361        case Fail{e}:
362          Fail{e}
363        case Done{acc}:
364          bpf_decode.go(t, 1n+pc, bpf_decode.push(BpfRaw.decode(r), BpfErrBadCode{pc, BpfRaw.code(r)}, acc))

Uses (10)

Used by (2)