collectScopeInfo() — react Function Reference
Architecture documentation for the collectScopeInfo() function in MergeOverlappingReactiveScopesHIR.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 20604946_1e38_3a1d_16f9_b7ef2a574d7c["collectScopeInfo()"] 78244170_3d42_f86a_ea59_bce3e065fcfd["MergeOverlappingReactiveScopesHIR.ts"] 20604946_1e38_3a1d_16f9_b7ef2a574d7c -->|defined in| 78244170_3d42_f86a_ea59_bce3e065fcfd ee1add24_e8b1_776d_87ba_d88fe78f7873["mergeOverlappingReactiveScopesHIR()"] ee1add24_e8b1_776d_87ba_d88fe78f7873 -->|calls| 20604946_1e38_3a1d_16f9_b7ef2a574d7c 14f2e51a_d755_814e_2f56_72d3ed119459["getOrInsertDefault()"] 20604946_1e38_3a1d_16f9_b7ef2a574d7c -->|calls| 14f2e51a_d755_814e_2f56_72d3ed119459 10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue()"] 20604946_1e38_3a1d_16f9_b7ef2a574d7c -->|calls| 10043bf1_f7ee_9ed9_307a_fe3edfd02b09 ccace1c3_85b7_a05e_c2a5_7eff8b3422ed["eachInstructionOperand()"] 20604946_1e38_3a1d_16f9_b7ef2a574d7c -->|calls| ccace1c3_85b7_a05e_c2a5_7eff8b3422ed 41232a25_deb6_6e83_05a8_ae9f961656f7["eachTerminalOperand()"] 20604946_1e38_3a1d_16f9_b7ef2a574d7c -->|calls| 41232a25_deb6_6e83_05a8_ae9f961656f7 style 20604946_1e38_3a1d_16f9_b7ef2a574d7c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts lines 149–198
function collectScopeInfo(fn: HIRFunction): ScopeInfo {
const scopeStarts: Map<InstructionId, Set<ReactiveScope>> = new Map();
const scopeEnds: Map<InstructionId, Set<ReactiveScope>> = new Map();
const placeScopes: Map<Place, ReactiveScope> = new Map();
function collectPlaceScope(place: Place): void {
const scope = place.identifier.scope;
if (scope != null) {
placeScopes.set(place, scope);
/**
* Record both mutating and non-mutating scopes to merge scopes with
* still-mutating values with inner scopes that alias those values
* (see `nonmutating-capture-in-unsplittable-memo-block`)
*
* Note that this isn't perfect, as it also leads to merging of mutating
* scopes with JSX single-instruction scopes (see `mutation-within-jsx`)
*/
if (scope.range.start !== scope.range.end) {
getOrInsertDefault(scopeStarts, scope.range.start, new Set()).add(
scope,
);
getOrInsertDefault(scopeEnds, scope.range.end, new Set()).add(scope);
}
}
}
for (const [, block] of fn.body.blocks) {
for (const instr of block.instructions) {
for (const operand of eachInstructionLValue(instr)) {
collectPlaceScope(operand);
}
for (const operand of eachInstructionOperand(instr)) {
collectPlaceScope(operand);
}
}
for (const operand of eachTerminalOperand(block.terminal)) {
collectPlaceScope(operand);
}
}
return {
scopeStarts: [...scopeStarts.entries()]
.map(([id, scopes]) => ({id, scopes}))
.sort((a, b) => b.id - a.id),
scopeEnds: [...scopeEnds.entries()]
.map(([id, scopes]) => ({id, scopes}))
.sort((a, b) => b.id - a.id),
placeScopes,
};
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does collectScopeInfo() do?
collectScopeInfo() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts.
Where is collectScopeInfo() defined?
collectScopeInfo() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts at line 149.
What does collectScopeInfo() call?
collectScopeInfo() calls 4 function(s): eachInstructionLValue, eachInstructionOperand, eachTerminalOperand, getOrInsertDefault.
What calls collectScopeInfo()?
collectScopeInfo() is called by 1 function(s): mergeOverlappingReactiveScopesHIR.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free