handleInstruction() — react Function Reference
Architecture documentation for the handleInstruction() function in PropagateScopeDependenciesHIR.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e["handleInstruction()"] 76832af2_c0a7_f31c_e448_af5664da4b88["PropagateScopeDependenciesHIR.ts"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|defined in| 76832af2_c0a7_f31c_e448_af5664da4b88 3cbb5167_d55c_6775_cfe5_cd15846ca8d2["findTemporariesUsedOutsideDeclaringScope()"] 3cbb5167_d55c_6775_cfe5_cd15846ca8d2 -->|calls| fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e 5b709ffb_65e9_2125_d608_a351c667cd6c["collectDependencies()"] 5b709ffb_65e9_2125_d608_a351c667cd6c -->|calls| fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e ad17cc28_c934_cf1a_ce40_409d2c34592d["inferDependenciesInFn()"] ad17cc28_c934_cf1a_ce40_409d2c34592d -->|calls| fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e 97736ed1_9768_bb5a_276e_d5b04a417908["declare()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| 97736ed1_9768_bb5a_276e_d5b04a417908 fda4793f_ce94_c900_cd2a_6dbe1a730c02["isDeferredDependency()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| fda4793f_ce94_c900_cd2a_6dbe1a730c02 8d8b17be_69f6_c901_0c65_675b2f52ffc0["visitProperty()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| 8d8b17be_69f6_c901_0c65_675b2f52ffc0 b9659720_c932_ebd9_335f_682c49188a34["visitOperand()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| b9659720_c932_ebd9_335f_682c49188a34 0b9af218_0f18_832f_3f27_3909263220a0["visitReassignment()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| 0b9af218_0f18_832f_3f27_3909263220a0 af0b93b3_d276_98ef_d04e_50e1568fb435["convertHoistedLValueKind()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| af0b93b3_d276_98ef_d04e_50e1568fb435 f5637d03_fd91_50b8_9da7_b2a24c91bab7["eachPatternOperand()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| f5637d03_fd91_50b8_9da7_b2a24c91bab7 a9451a62_0379_c394_befb_99acd7445bd9["hasDeclared()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| a9451a62_0379_c394_befb_99acd7445bd9 b2fc2985_a7ba_9865_c2a3_2a7531f27d44["eachInstructionValueOperand()"] fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e -->|calls| b2fc2985_a7ba_9865_c2a3_2a7531f27d44 style fe7b2dbb_34c7_f07a_c558_c479a9c5eb1e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts lines 667–745
export function handleInstruction(
instr: Instruction,
context: DependencyCollectionContext,
): void {
const {id, value, lvalue} = instr;
context.declare(lvalue.identifier, {
id,
scope: context.currentScope,
});
if (
context.isDeferredDependency({kind: HIRValue.Instruction, value: instr})
) {
return;
}
if (value.kind === 'PropertyLoad') {
context.visitProperty(value.object, value.property, false);
} else if (value.kind === 'StoreLocal') {
context.visitOperand(value.value);
if (value.lvalue.kind === InstructionKind.Reassign) {
context.visitReassignment(value.lvalue.place);
}
context.declare(value.lvalue.place.identifier, {
id,
scope: context.currentScope,
});
} else if (value.kind === 'DeclareLocal' || value.kind === 'DeclareContext') {
/*
* Some variables may be declared and never initialized. We need to retain
* (and hoist) these declarations if they are included in a reactive scope.
* One approach is to simply add all `DeclareLocal`s as scope declarations.
*
* Context variables with hoisted declarations only become live after their
* first assignment. We only declare real DeclareLocal / DeclareContext
* instructions (not hoisted ones) to avoid generating dependencies on
* hoisted declarations.
*/
if (convertHoistedLValueKind(value.lvalue.kind) === null) {
context.declare(value.lvalue.place.identifier, {
id,
scope: context.currentScope,
});
}
} else if (value.kind === 'Destructure') {
context.visitOperand(value.value);
for (const place of eachPatternOperand(value.lvalue.pattern)) {
if (value.lvalue.kind === InstructionKind.Reassign) {
context.visitReassignment(place);
}
context.declare(place.identifier, {
id,
scope: context.currentScope,
});
}
} else if (value.kind === 'StoreContext') {
/**
* Some StoreContext variables have hoisted declarations. If we're storing
* to a context variable that hasn't yet been declared, the StoreContext is
* the declaration.
* (see corresponding logic in PruneHoistedContext)
*/
if (
!context.hasDeclared(value.lvalue.place.identifier) ||
value.lvalue.kind !== InstructionKind.Reassign
) {
context.declare(value.lvalue.place.identifier, {
id,
scope: context.currentScope,
});
}
for (const operand of eachInstructionValueOperand(value)) {
context.visitOperand(operand);
}
} else {
for (const operand of eachInstructionValueOperand(value)) {
context.visitOperand(operand);
}
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does handleInstruction() do?
handleInstruction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts.
Where is handleInstruction() defined?
handleInstruction() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts at line 667.
What does handleInstruction() call?
handleInstruction() calls 9 function(s): convertHoistedLValueKind, declare, eachInstructionValueOperand, eachPatternOperand, hasDeclared, isDeferredDependency, visitOperand, visitProperty, and 1 more.
What calls handleInstruction()?
handleInstruction() is called by 3 function(s): collectDependencies, findTemporariesUsedOutsideDeclaringScope, inferDependenciesInFn.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free