def pt_store

bendtorch@1.3.0.0 · main.bend:3398

import bendtorch@1.3.0.0/main.bend as Bendtorch
import Base

3398# the tree's cells into xs from off
3399def pt_store(t: PTree, xs: Array<F32>, +off: U32) -> PTA:
3400  match t:
3401    case PNew{+v16}:
3402      PTA{PNew{v16}, Array.set(F32, Array.set(F32, xs, off, ph_u2f(0)), (off + 1 : U32), ph_u2f(ph_bool(v16))), (off + 2 : U32)}
3403    case PLeaf{+n, m, v}:
3404      pts_m(n, v, (off + 2 : U32), words_out(U32.to_nat(ph_hw(n)), 0, (off + 2 : U32), Array.get(U32, m, 0), Array.set(F32, Array.set(F32, xs, off, ph_u2f(2)), (off + 1 : U32), ph_u2f(n))))
3405    case PLeafV{+n, m, v}:
3406      ptsv_m(n, v, (off + 2 : U32), words_out(U32.to_nat(ph_hw(n)), 0, (off + 2 : U32), Array.get(U32, m, 0), Array.set(F32, Array.set(F32, xs, off, ph_u2f(3)), (off + 1 : U32), ph_u2f(n))))
3407    case PNode{a, b}:
3408      pta_then(pt_store(a, Array.set(F32, xs, off, ph_u2f(1)), (off + 1 : U32)), ta => xs2 => off2 => pta_node(ta, pt_store(b, xs2, off2)))

Uses (17)

Used by (2)