lower() — react Function Reference
Architecture documentation for the lower() function in BuildHIR.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD f214c28b_2f6d_b5a3_71e1_9a69d9b50455["lower()"] e04c04d6_37a7_1dc3_7fae_7d07660d0af9["BuildHIR.ts"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|defined in| e04c04d6_37a7_1dc3_7fae_7d07660d0af9 535369af_370f_d1a4_e72e_56482eceef72["lowerFunction()"] 535369af_370f_d1a4_e72e_56482eceef72 -->|calls| f214c28b_2f6d_b5a3_71e1_9a69d9b50455 cf4d0005_5527_42f1_2412_741dbace1899["resolveBinding()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| cf4d0005_5527_42f1_2412_741dbace1899 d5e0302e_0924_3d1c_bfcb_bc2180bf984c["hasNode()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| d5e0302e_0924_3d1c_bfcb_bc2180bf984c c753d1dc_3d72_6c26_43d1_a3614937be80["resolveIdentifier()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| c753d1dc_3d72_6c26_43d1_a3614937be80 02303def_636f_c5b3_a751_1cf138fcea69["pushDiagnostic()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| 02303def_636f_c5b3_a751_1cf138fcea69 ac13f5c1_be17_dd7a_6bd3_66d91c46aadf["create()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| ac13f5c1_be17_dd7a_6bd3_66d91c46aadf 1a2b7047_24c8_62d6_b328_5f07307d27ab["withDetails()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| 1a2b7047_24c8_62d6_b328_5f07307d27ab 17407413_2252_f037_c1e8_b453546fbe66["makeTemporary()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| 17407413_2252_f037_c1e8_b453546fbe66 216a4c34_910d_7936_33eb_adf13df70310["promoteTemporary()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| 216a4c34_910d_7936_33eb_adf13df70310 b98634fa_1f83_e1bb_1406_d07e28c93b41["lowerAssignment()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| b98634fa_1f83_e1bb_1406_d07e28c93b41 2a23449a_1dec_0ba3_8f5a_0e9e83d42add["reserve()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| 2a23449a_1dec_0ba3_8f5a_0e9e83d42add 5bae3f87_1b76_e568_9b44_1d2fb59f73d8["lowerExpressionToTemporary()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| 5bae3f87_1b76_e568_9b44_1d2fb59f73d8 d0270ab6_a621_bd55_a1b9_a5cad8b406b2["makeInstructionId()"] f214c28b_2f6d_b5a3_71e1_9a69d9b50455 -->|calls| d0270ab6_a621_bd55_a1b9_a5cad8b406b2 style f214c28b_2f6d_b5a3_71e1_9a69d9b50455 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts lines 72–264
export function lower(
func: NodePath<t.Function>,
env: Environment,
// Bindings captured from the outer function, in case lower() is called recursively (for lambdas)
bindings: Bindings | null = null,
capturedRefs: Map<t.Identifier, SourceLocation> = new Map(),
): Result<HIRFunction, CompilerError> {
const builder = new HIRBuilder(env, {
bindings,
context: capturedRefs,
});
const context: HIRFunction['context'] = [];
for (const [ref, loc] of capturedRefs ?? []) {
context.push({
kind: 'Identifier',
identifier: builder.resolveBinding(ref),
effect: Effect.Unknown,
reactive: false,
loc,
});
}
let id: string | null = null;
if (func.isFunctionDeclaration() || func.isFunctionExpression()) {
const idNode = (
func as NodePath<t.FunctionDeclaration | t.FunctionExpression>
).get('id');
if (hasNode(idNode)) {
id = idNode.node.name;
}
}
const params: Array<Place | SpreadPattern> = [];
func.get('params').forEach(param => {
if (param.isIdentifier()) {
const binding = builder.resolveIdentifier(param);
if (binding.kind !== 'Identifier') {
builder.errors.pushDiagnostic(
CompilerDiagnostic.create({
category: ErrorCategory.Invariant,
reason: 'Could not find binding',
description: `[BuildHIR] Could not find binding for param \`${param.node.name}\``,
}).withDetails({
kind: 'error',
loc: param.node.loc ?? null,
message: 'Could not find binding',
}),
);
return;
}
const place: Place = {
kind: 'Identifier',
identifier: binding.identifier,
effect: Effect.Unknown,
reactive: false,
loc: param.node.loc ?? GeneratedSource,
};
params.push(place);
} else if (
param.isObjectPattern() ||
param.isArrayPattern() ||
param.isAssignmentPattern()
) {
const place: Place = {
kind: 'Identifier',
identifier: builder.makeTemporary(param.node.loc ?? GeneratedSource),
effect: Effect.Unknown,
reactive: false,
loc: param.node.loc ?? GeneratedSource,
};
promoteTemporary(place.identifier);
params.push(place);
lowerAssignment(
builder,
param.node.loc ?? GeneratedSource,
InstructionKind.Let,
param,
place,
'Assignment',
);
} else if (param.isRestElement()) {
Domain
Subdomains
Calls
- Err()
- Ok()
- build()
- create()
- createTemporaryPlace()
- hasAnyErrors()
- hasNode()
- isErr()
- lowerAssignment()
- lowerExpressionToTemporary()
- lowerStatement()
- lowerValueToTemporary()
- makeInstructionId()
- makeTemporary()
- map()
- merge()
- promoteTemporary()
- push()
- pushDiagnostic()
- reserve()
- resolveBinding()
- resolveIdentifier()
- terminate()
- terminateWithContinuation()
- unwrap()
- unwrapErr()
- validateIdentifierName()
- withDetails()
Called By
Source
Frequently Asked Questions
What does lower() do?
lower() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts.
Where is lower() defined?
lower() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts at line 72.
What does lower() call?
lower() calls 28 function(s): Err, Ok, build, create, createTemporaryPlace, hasAnyErrors, hasNode, isErr, and 20 more.
What calls lower()?
lower() is called by 1 function(s): lowerFunction.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free