Skip to main content

Crate react_compiler_reactive_scopes

Crate react_compiler_reactive_scopes 

Source
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 ReactiveFunction tree 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