codegenInstructionNullable() — react Function Reference
Architecture documentation for the codegenInstructionNullable() function in CodegenReactiveFunction.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD c65f3ebd_fe8f_602d_b885_bc79e6e81b1d["codegenInstructionNullable()"] dc7f10c2_c914_a162_d02b_a10a15c64a5f["CodegenReactiveFunction.ts"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|defined in| dc7f10c2_c914_a162_d02b_a10a15c64a5f 6913ca73_f3c4_9919_bf65_7b95559378b7["codegenBlockNoReset()"] 6913ca73_f3c4_9919_bf65_7b95559378b7 -->|calls| c65f3ebd_fe8f_602d_b885_bc79e6e81b1d 43b28878_9b1d_6aeb_0d77_25080004044d["hasDeclared()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| 43b28878_9b1d_6aeb_0d77_25080004044d 0b424541_28a8_fc42_ac4b_b6ae2672cb88["codegenPlaceToExpression()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| 0b424541_28a8_fc42_ac4b_b6ae2672cb88 f5637d03_fd91_50b8_9da7_b2a24c91bab7["eachPatternOperand()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| f5637d03_fd91_50b8_9da7_b2a24c91bab7 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e 6a903108_0a0b_6e52_019e_0b534b909b09["createVariableDeclarator()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| 6a903108_0a0b_6e52_019e_0b534b909b09 fa00221c_3f87_f634_2655_5b0ca5860306["codegenLValue()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| fa00221c_3f87_f634_2655_5b0ca5860306 1bdf9e01_ffb0_1422_a451_e62965a1969b["printInstruction()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| 1bdf9e01_ffb0_1422_a451_e62965a1969b e98029e7_d319_5eee_1233_4a0434b62d22["codegenInstruction()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| e98029e7_d319_5eee_1233_4a0434b62d22 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6 d8edf87e_ea78_c9d0_b5c9_13d68891efec["codegenInstructionValue()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| d8edf87e_ea78_c9d0_b5c9_13d68891efec style c65f3ebd_fe8f_602d_b885_bc79e6e81b1d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts lines 1227–1380
function codegenInstructionNullable(
cx: Context,
instr: ReactiveInstruction,
): t.Statement | null {
if (
instr.value.kind === 'StoreLocal' ||
instr.value.kind === 'StoreContext' ||
instr.value.kind === 'Destructure' ||
instr.value.kind === 'DeclareLocal' ||
instr.value.kind === 'DeclareContext'
) {
let kind: InstructionKind = instr.value.lvalue.kind;
let lvalue: Place | Pattern;
let value: t.Expression | null;
if (instr.value.kind === 'StoreLocal') {
kind = cx.hasDeclared(instr.value.lvalue.place.identifier)
? InstructionKind.Reassign
: kind;
lvalue = instr.value.lvalue.place;
value = codegenPlaceToExpression(cx, instr.value.value);
} else if (instr.value.kind === 'StoreContext') {
lvalue = instr.value.lvalue.place;
value = codegenPlaceToExpression(cx, instr.value.value);
} else if (
instr.value.kind === 'DeclareLocal' ||
instr.value.kind === 'DeclareContext'
) {
if (cx.hasDeclared(instr.value.lvalue.place.identifier)) {
return null;
}
kind = instr.value.lvalue.kind;
lvalue = instr.value.lvalue.place;
value = null;
} else {
lvalue = instr.value.lvalue.pattern;
for (const place of eachPatternOperand(lvalue)) {
if (
kind !== InstructionKind.Reassign &&
place.identifier.name === null
) {
cx.temp.set(place.identifier.declarationId, null);
}
}
value = codegenPlaceToExpression(cx, instr.value.value);
}
switch (kind) {
case InstructionKind.Const: {
CompilerError.invariant(instr.lvalue === null, {
reason: `Const declaration cannot be referenced as an expression`,
message: `this is ${kind}`,
loc: instr.value.loc,
});
return createVariableDeclaration(instr.loc, 'const', [
createVariableDeclarator(codegenLValue(cx, lvalue), value),
]);
}
case InstructionKind.Function: {
CompilerError.invariant(instr.lvalue === null, {
reason: `Function declaration cannot be referenced as an expression`,
loc: instr.value.loc,
});
const genLvalue = codegenLValue(cx, lvalue);
CompilerError.invariant(genLvalue.type === 'Identifier', {
reason: 'Expected an identifier as a function declaration lvalue',
loc: instr.value.loc,
});
CompilerError.invariant(value?.type === 'FunctionExpression', {
reason: 'Expected a function as a function declaration value',
description: `Got ${value == null ? String(value) : value.type} at ${printInstruction(instr)}`,
loc: instr.value.loc,
});
return createFunctionDeclaration(
instr.loc,
genLvalue,
value.params,
value.body,
value.generator,
value.async,
);
}
case InstructionKind.Let: {
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does codegenInstructionNullable() do?
codegenInstructionNullable() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts.
Where is codegenInstructionNullable() defined?
codegenInstructionNullable() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts at line 1227.
What does codegenInstructionNullable() call?
codegenInstructionNullable() calls 10 function(s): assertExhaustive, codegenInstruction, codegenInstructionValue, codegenLValue, codegenPlaceToExpression, createVariableDeclarator, eachPatternOperand, hasDeclared, and 2 more.
What calls codegenInstructionNullable()?
codegenInstructionNullable() is called by 1 function(s): codegenBlockNoReset.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free