flattenReactiveLoopsHIR() — react Function Reference
Architecture documentation for the flattenReactiveLoopsHIR() function in FlattenReactiveLoopsHIR.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca["flattenReactiveLoopsHIR()"] 17d394b5_a235_d9d6_15c9_133daa2aab98["FlattenReactiveLoopsHIR.ts"] 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca -->|defined in| 17d394b5_a235_d9d6_15c9_133daa2aab98 c3bc3875_256f_8f5e_7800_2f9c5bae65eb["runWithEnvironment()"] c3bc3875_256f_8f5e_7800_2f9c5bae65eb -->|calls| 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca c447b97e_0b8e_b187_e3a8_4be412d6f495["retainWhere()"] 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"] 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6 style 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/FlattenReactiveLoopsHIR.ts lines 18–71
export function flattenReactiveLoopsHIR(fn: HIRFunction): void {
const activeLoops = Array<BlockId>();
for (const [, block] of fn.body.blocks) {
retainWhere(activeLoops, id => id !== block.id);
const {terminal} = block;
switch (terminal.kind) {
case 'do-while':
case 'for':
case 'for-in':
case 'for-of':
case 'while': {
activeLoops.push(terminal.fallthrough);
break;
}
case 'scope': {
if (activeLoops.length !== 0) {
block.terminal = {
kind: 'pruned-scope',
block: terminal.block,
fallthrough: terminal.fallthrough,
id: terminal.id,
loc: terminal.loc,
scope: terminal.scope,
} as PrunedScopeTerminal;
}
break;
}
case 'branch':
case 'goto':
case 'if':
case 'label':
case 'logical':
case 'maybe-throw':
case 'optional':
case 'pruned-scope':
case 'return':
case 'sequence':
case 'switch':
case 'ternary':
case 'throw':
case 'try':
case 'unreachable':
case 'unsupported': {
break;
}
default: {
assertExhaustive(
terminal,
`Unexpected terminal kind \`${(terminal as any).kind}\``,
);
}
}
}
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does flattenReactiveLoopsHIR() do?
flattenReactiveLoopsHIR() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/FlattenReactiveLoopsHIR.ts.
Where is flattenReactiveLoopsHIR() defined?
flattenReactiveLoopsHIR() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/FlattenReactiveLoopsHIR.ts at line 18.
What does flattenReactiveLoopsHIR() call?
flattenReactiveLoopsHIR() calls 2 function(s): assertExhaustive, retainWhere.
What calls flattenReactiveLoopsHIR()?
flattenReactiveLoopsHIR() is called by 1 function(s): runWithEnvironment.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free