The copyTree routine #
Copying (or skipping) a preorder-serialized value: a scan with a unary counter of the
pending subtrees on CNT, one more per 1 (a node with two children, itself consumed) and
one fewer per 0 (a leaf), finishing when none is pending. The scan from d ≥ 1 pending
subtrees over S(v) leaves d - 1 pending (copyTree_scan), finishing when d = 1; the
instruction starts with one (exec_copyTree).
The control at (k, pc, p1) if d ≠ 1, else at the next instruction.
Equations
- MIPRE.TM.Interp.scanExit k pc hpc d = if d = 1 then MIPRE.TM.Interp.next_ k pc hpc else some { k := k, pc := pc, ph := MIPRE.TM.Interp.Phase.p1 }
Instances For
One written symbol.
The scan of copyTree src (some t) false over S(v) from d ≥ 1 pending subtrees.
The scan of copyTree src none false (a skip) over S(v) from d ≥ 1 pending
subtrees.
The first phase of copyTree: one pending subtree.
copyTree src (some t) false: copy S(v) from the head of src to the head of
t, in at most 3 |v| + 1 steps.
copyTree src none false: skip S(v) on src, in at most 3 |v| + 1 steps.