lowerAssignment() — react Function Reference
Architecture documentation for the lowerAssignment() function in BuildHIR.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD b98634fa_1f83_e1bb_1406_d07e28c93b41["lowerAssignment()"] e04c04d6_37a7_1dc3_7fae_7d07660d0af9["BuildHIR.ts"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|defined in| e04c04d6_37a7_1dc3_7fae_7d07660d0af9 f214c28b_2f6d_b5a3_71e1_9a69d9b50455["lower()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| b98634fa_1f83_e1bb_1406_d07e28c93b41 c01b12bd_811d_9f90_f641_fac8e518dbb7["lowerStatement()"] c01b12bd_811d_9f90_f641_fac8e518dbb7 -->|calls| b98634fa_1f83_e1bb_1406_d07e28c93b41 ace1177a_10b2_b870_31fd_da4aa845554c["lowerExpression()"] ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| b98634fa_1f83_e1bb_1406_d07e28c93b41 d647d797_7545_2cf1_8751_866151e2ddee["lowerIdentifierForAssignment()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| d647d797_7545_2cf1_8751_866151e2ddee f1f0c182_09ad_b29e_b1ca_56f10046adff["lowerValueToTemporary()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| f1f0c182_09ad_b29e_b1ca_56f10046adff 129cba6c_ded6_779e_cc49_b175d871418b["isHoistedIdentifier()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| 129cba6c_ded6_779e_cc49_b175d871418b 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e 5bae3f87_1b76_e568_9b44_1d2fb59f73d8["lowerExpressionToTemporary()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| 5bae3f87_1b76_e568_9b44_1d2fb59f73d8 3532df9c_cf42_5889_99aa_db6c6d3e1708["makePropertyLiteral()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| 3532df9c_cf42_5889_99aa_db6c6d3e1708 63369f82_2d96_a4ab_e404_a9089a5e6492["getStoreKind()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| 63369f82_2d96_a4ab_e404_a9089a5e6492 c753d1dc_3d72_6c26_43d1_a3614937be80["resolveIdentifier()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| c753d1dc_3d72_6c26_43d1_a3614937be80 147a0e7f_dab2_6a99_0c59_2eb8b07f70d5["buildTemporaryPlace()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| 147a0e7f_dab2_6a99_0c59_2eb8b07f70d5 216a4c34_910d_7936_33eb_adf13df70310["promoteTemporary()"] b98634fa_1f83_e1bb_1406_d07e28c93b41 -->|calls| 216a4c34_910d_7936_33eb_adf13df70310 style b98634fa_1f83_e1bb_1406_d07e28c93b41 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts lines 3660–4220
function lowerAssignment(
builder: HIRBuilder,
loc: SourceLocation,
kind: InstructionKind,
lvaluePath: NodePath<t.LVal>,
value: Place,
assignmentKind: 'Destructure' | 'Assignment',
): InstructionValue {
const lvalueNode = lvaluePath.node;
switch (lvalueNode.type) {
case 'Identifier': {
const lvalue = lvaluePath as NodePath<t.Identifier>;
const place = lowerIdentifierForAssignment(builder, loc, kind, lvalue);
if (place === null) {
return {
kind: 'UnsupportedNode',
loc: lvalue.node.loc ?? GeneratedSource,
node: lvalue.node,
};
} else if (place.kind === 'Global') {
const temporary = lowerValueToTemporary(builder, {
kind: 'StoreGlobal',
name: place.name,
value,
loc,
});
return {kind: 'LoadLocal', place: temporary, loc: temporary.loc};
}
const isHoistedIdentifier = builder.environment.isHoistedIdentifier(
lvalue.node,
);
let temporary;
if (builder.isContextIdentifier(lvalue)) {
if (kind === InstructionKind.Const && !isHoistedIdentifier) {
builder.errors.push({
reason: `Expected \`const\` declaration not to be reassigned`,
category: ErrorCategory.Syntax,
loc: lvalue.node.loc ?? null,
suggestions: null,
});
}
if (
kind !== InstructionKind.Const &&
kind !== InstructionKind.Reassign &&
kind !== InstructionKind.Let &&
kind !== InstructionKind.Function
) {
builder.errors.push({
reason: `Unexpected context variable kind`,
category: ErrorCategory.Syntax,
loc: lvalue.node.loc ?? null,
suggestions: null,
});
temporary = lowerValueToTemporary(builder, {
kind: 'UnsupportedNode',
node: lvalueNode,
loc: lvalueNode.loc ?? GeneratedSource,
});
} else {
temporary = lowerValueToTemporary(builder, {
kind: 'StoreContext',
lvalue: {place: {...place}, kind},
value,
loc,
});
}
} else {
const typeAnnotation = lvalue.get('typeAnnotation');
let type: t.FlowType | t.TSType | null;
if (typeAnnotation.isTSTypeAnnotation()) {
const typePath = typeAnnotation.get('typeAnnotation');
type = typePath.node;
} else if (typeAnnotation.isTypeAnnotation()) {
const typePath = typeAnnotation.get('typeAnnotation');
type = typePath.node;
} else {
type = null;
}
temporary = lowerValueToTemporary(builder, {
Domain
Subdomains
Calls
- buildTemporaryPlace()
- currentBlockKind()
- enter()
- getStoreKind()
- invariant()
- isContextIdentifier()
- isHoistedIdentifier()
- lowerExpressionToTemporary()
- lowerIdentifierForAssignment()
- lowerObjectPropertyKey()
- lowerReorderableExpression()
- lowerValueToTemporary()
- makeInstructionId()
- makePropertyLiteral()
- promoteTemporary()
- push()
- reserve()
- resolveIdentifier()
- terminateWithContinuation()
Called By
Source
Frequently Asked Questions
What does lowerAssignment() do?
lowerAssignment() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts.
Where is lowerAssignment() defined?
lowerAssignment() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts at line 3660.
What does lowerAssignment() call?
lowerAssignment() calls 19 function(s): buildTemporaryPlace, currentBlockKind, enter, getStoreKind, invariant, isContextIdentifier, isHoistedIdentifier, lowerExpressionToTemporary, and 11 more.
What calls lowerAssignment()?
lowerAssignment() is called by 3 function(s): lower, lowerExpression, lowerStatement.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free