Skip to main content

Module rewrite

Module rewrite 

Source
Expand description

The rewriting pass.

Rewriter walks the function with syn’s VisitMut, innermost blocks first. In every block of async code it

  1. hands for and while loops to crate::loops,
  2. exposes awaits hidden inside larger statements (Rewriter::expose_awaits),
  3. splits the block into regions at barriers and schedules each region (crate::schedule).

A block whose regions all stay sequential is emitted exactly as written.

StructsΒ§

Rewriter πŸ”’
The state of one #[psync::graph] expansion.

ConstantsΒ§

MAX_HOIST_DEPTH πŸ”’
How many times a statement may be split while exposing nested awaits.

FunctionsΒ§

awaited_value πŸ”’
Whether a let’s value is itself awaited (x.await, x.await?, x.await.len()), so the binding is already a node of its own await and there is nothing to expose.
bind_values πŸ”’
Record what stmt’s bindings name. A let of one immutable name binds the target its value names, if that says more than β€œanything” and depends on no mut binding (so it is the same value wherever the name is used). Any binding forgets what was known of its name, and of the values computed from it (they were computed from the shadowed one).
is_control_flow πŸ”’
A statement that is, or binds, a branch or a loop.