Expand description
Reactive scope passes for the React Compiler.
Converts the HIR CFG into a tree-structured ReactiveFunction and runs
scope-related transformation passes (pruning, merging, renaming, etc.).
Corresponds to src/ReactiveScopes/ in the TypeScript compiler.
Re-exports§
pub use codegen_reactive_function::codegen_function;pub use print_reactive_function::debug_reactive_function;
Modules§
- codegen_
reactive_ function - Code generation pass: converts a
ReactiveFunctiontree back into a Babel-compatible AST with memoization (useMemoCache) wired in. - print_
reactive_ function - Verbose debug printer for ReactiveFunction.
- visitors
- Visitor and transform traits for ReactiveFunction.
Functions§
- assert_
scope_ instructions_ within_ scopes - Assert that scope instructions are within their scopes. Two-pass visitor:
- assert_
well_ formed_ break_ targets - Assert that all break/continue targets reference existent labels.
- build_
reactive_ function - Convert the HIR CFG into a tree-structured ReactiveFunction.
- extract_
scope_ declarations_ from_ destructuring - Extracts scope declarations from destructuring patterns where some bindings
are scope declarations and others aren’t.
TS:
extractScopeDeclarationsFromDestructuring - merge_
reactive_ scopes_ that_ invalidate_ together - Merges adjacent reactive scopes that share dependencies (invalidate together).
TS:
mergeReactiveScopesThatInvalidateTogether - promote_
used_ temporaries - Promotes temporary (unnamed) identifiers used in scopes to named identifiers.
TS:
promoteUsedTemporaries - propagate_
early_ returns - Propagate early return semantics through reactive scopes.
TS:
propagateEarlyReturns - prune_
always_ invalidating_ scopes - Prunes scopes that always invalidate because they depend on unmemoized
always-invalidating values.
TS:
pruneAlwaysInvalidatingScopes - prune_
hoisted_ contexts - Prunes DeclareContexts lowered for HoistedConsts and transforms any
references back to their original instruction kind.
TS:
pruneHoistedContexts - prune_
non_ escaping_ scopes - Prunes reactive scopes whose outputs don’t escape.
TS:
pruneNonEscapingScopes - prune_
non_ reactive_ dependencies - Prunes dependencies that are guaranteed to be non-reactive.
TS:
pruneNonReactiveDependencies - prune_
unused_ labels - Prune unused labels from a reactive function.
- prune_
unused_ lvalues - Nulls out lvalues for unnamed temporaries that are never used.
TS:
pruneUnusedLValues - prune_
unused_ scopes - Converts scopes without outputs into pruned-scopes (regular blocks).
TS:
pruneUnusedScopes - rename_
variables - Renames variables for output — assigns unique names, handles SSA renames.
Returns a Set of all unique variable names used.
TS:
renameVariables - stabilize_
block_ ids - Rewrites block IDs to sequential values.
TS:
stabilizeBlockIds