PromoteUsedTemporaries.ts — react Source File
Architecture documentation for PromoteUsedTemporaries.ts, a typescript file in the react codebase. 25 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6["PromoteUsedTemporaries.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> e96f281e_f381_272d_2359_3e6a091c9a1d e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> e51fd0d2_bb38_cc97_7763_efe37f300a47 0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> 0423f759_97e0_9101_4634_ed555abc5ca9 18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> 18a78965_f593_105b_e5e8_07001321c2ec bf1aef24_2e0f_0adb_12d8_9e5ba8245644["DeclarationId"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> bf1aef24_2e0f_0adb_12d8_9e5ba8245644 bd003dbd_e691_524b_0cf4_50e080ffea94["Identifier"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> bd003dbd_e691_524b_0cf4_50e080ffea94 23767d65_9554_fcd2_f2aa_7de7634389f9["InstructionId"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> 23767d65_9554_fcd2_f2aa_7de7634389f9 c7aaa235_c19e_3530_31c2_911f38eed3e0["Place"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> c7aaa235_c19e_3530_31c2_911f38eed3e0 02f69dfe_af02_6deb_8891_1b0229142fd1["PrunedReactiveScopeBlock"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> 02f69dfe_af02_6deb_8891_1b0229142fd1 c0555545_1ea3_9d37_62ad_521eafe2daa8["ReactiveFunction"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> c0555545_1ea3_9d37_62ad_521eafe2daa8 ca9a6820_460e_0b15_8169_3aa4c6503770["ReactiveScope"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> ca9a6820_460e_0b15_8169_3aa4c6503770 60e40c84_1324_6a2b_a7cf_f69d86f17579["ReactiveInstruction"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> 60e40c84_1324_6a2b_a7cf_f69d86f17579 0fba6722_c385_0076_d75b_47ee3ff87ee3["ReactiveScopeBlock"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> 0fba6722_c385_0076_d75b_47ee3ff87ee3 03931fe0_84fd_a4e9_b75a_03f9d092be95["ReactiveValue"] dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 --> 03931fe0_84fd_a4e9_b75a_03f9d092be95 style dea6b9e7_3c69_6e86_5d64_ba83c7d43ed6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {CompilerError} from '../CompilerError';
import {GeneratedSource} from '../HIR';
import {
DeclarationId,
Identifier,
InstructionId,
Place,
PrunedReactiveScopeBlock,
ReactiveFunction,
ReactiveScope,
ReactiveInstruction,
ReactiveScopeBlock,
ReactiveValue,
ScopeId,
SpreadPattern,
promoteTemporary,
promoteTemporaryJsxTag,
IdentifierId,
} from '../HIR/HIR';
import {ReactiveFunctionVisitor, visitReactiveFunction} from './visitors';
import {eachInstructionValueLValue, eachPatternOperand} from '../HIR/visitors';
/**
* Phase 2: Promote identifiers which are used in a place that requires a named variable.
*/
class PromoteTemporaries extends ReactiveFunctionVisitor<State> {
override visitScope(scopeBlock: ReactiveScopeBlock, state: State): void {
for (const dep of scopeBlock.scope.dependencies) {
const {identifier} = dep;
if (identifier.name == null) {
promoteIdentifier(identifier, state);
}
}
/*
* This is technically optional. We could prune ReactiveScopes
* whose outputs are not used in another computation or return
* value.
* Many of our current test fixtures do not return a value, so
* it is better for now to promote (and memoize) every output.
*/
for (const [, declaration] of scopeBlock.scope.declarations) {
if (declaration.identifier.name == null) {
promoteIdentifier(declaration.identifier, state);
}
}
this.traverseScope(scopeBlock, state);
}
override visitPrunedScope(
scopeBlock: PrunedReactiveScopeBlock,
state: State,
): void {
for (const [, declaration] of scopeBlock.scope.declarations) {
// ... (405 more lines)
Domain
Subdomains
Classes
Dependencies
- CompilerError
- CompilerError.ts
- DeclarationId
- HIR.ts
- Identifier
- IdentifierId
- InstructionId
- Place
- PrunedReactiveScopeBlock
- ReactiveFunction
- ReactiveFunctionVisitor
- ReactiveInstruction
- ReactiveScope
- ReactiveScopeBlock
- ReactiveValue
- ScopeId
- SpreadPattern
- eachInstructionValueLValue
- eachPatternOperand
- index.ts
- promoteTemporary
- promoteTemporaryJsxTag
- visitReactiveFunction
- visitors.ts
- visitors.ts
Source
Frequently Asked Questions
What does PromoteUsedTemporaries.ts do?
PromoteUsedTemporaries.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in PromoteUsedTemporaries.ts?
PromoteUsedTemporaries.ts defines 2 function(s): promoteIdentifier, promoteUsedTemporaries.
What does PromoteUsedTemporaries.ts depend on?
PromoteUsedTemporaries.ts imports 25 module(s): CompilerError, CompilerError.ts, DeclarationId, HIR.ts, Identifier, IdentifierId, InstructionId, Place, and 17 more.
Where is PromoteUsedTemporaries.ts in the architecture?
PromoteUsedTemporaries.ts is located at compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PromoteUsedTemporaries.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free