step.motion.path.passes.lowering

Lowering pass — turn a tree of Step objects into the path IR.

This is the entry point of the pipeline. It walks the Step tree, recursively flattens Sequential and Parallel composites into a linear node list, identifies the motion spine inside parallel branches, and produces:

  • list[Optional[PathNode]] — flat path nodes (Segments, SideActions, or None placeholders for deferred steps).

  • list[tuple[int, Defer]] — deferred entries to resolve at runtime, keyed by their index in the node list.

Functions

extract_segment(→ step.motion.path.ir.Segment)

Extract motion IR from a resolved step via its lower_to_segments().

resolve_step(→ step.Step)

Resolve a builder to a concrete Step instance.

is_same_type(→ bool)

Check if two segments can use warm-start (same motion type).

flatten_one(→ None)

Recursively flatten step into path nodes.

flatten_parallel(→ None)

Flatten a Parallel step, identifying the motion spine branch.

flatten_steps(...)

Flatten a list of steps into a linear path.

Module Contents

step.motion.path.passes.lowering.extract_segment(step: step.Step) step.motion.path.ir.Segment

Extract motion IR from a resolved step via its lower_to_segments().

A step that is not optimizer-supported returns None and is rejected here with TypeError so flatten_one can treat it as a side action.

step.motion.path.passes.lowering.resolve_step(step) step.Step

Resolve a builder to a concrete Step instance.

step.motion.path.passes.lowering.is_same_type(a: step.motion.path.ir.Segment, b: step.motion.path.ir.Segment) bool

Check if two segments can use warm-start (same motion type).

follow_line is treated as a forward linear for warm-start purposes: it runs the same LinearMotion axis internally, so velocity can be carried across linear(Forward) follow_line transitions. spline never warm-starts.

step.motion.path.passes.lowering.flatten_one(step, nodes: list[step.motion.path.ir.PathNode | None], deferred: list[tuple[int, step.logic.defer.Defer]]) None

Recursively flatten step into path nodes.

Appends to nodes in-place. Deferred steps become None placeholders with entries in deferred for runtime resolution.

step.motion.path.passes.lowering.flatten_parallel(par, nodes: list[step.motion.path.ir.PathNode | None], deferred: list[tuple[int, step.logic.defer.Defer]]) None

Flatten a Parallel step, identifying the motion spine branch.

step.motion.path.passes.lowering.flatten_steps(steps: list) tuple[list[step.motion.path.ir.PathNode | None], list[tuple[int, step.logic.defer.Defer]]]

Flatten a list of steps into a linear path.

Returns:

(nodes, deferred) where nodes is a flat list of Segment, SideAction, or None (deferred placeholder), and deferred is a list of (index, Defer) pairs for runtime resolution.