codegenInstructionValue() — react Function Reference
Architecture documentation for the codegenInstructionValue() function in CodegenReactiveFunction.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD d8edf87e_ea78_c9d0_b5c9_13d68891efec["codegenInstructionValue()"] dc7f10c2_c914_a162_d02b_a10a15c64a5f["CodegenReactiveFunction.ts"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|defined in| dc7f10c2_c914_a162_d02b_a10a15c64a5f c65f3ebd_fe8f_602d_b885_bc79e6e81b1d["codegenInstructionNullable()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| d8edf87e_ea78_c9d0_b5c9_13d68891efec d2920090_42bc_7919_897f_42680a08ace6["codegenInstructionValueToExpression()"] d2920090_42bc_7919_897f_42680a08ace6 -->|calls| d8edf87e_ea78_c9d0_b5c9_13d68891efec 0b424541_28a8_fc42_ac4b_b6ae2672cb88["codegenPlaceToExpression()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 0b424541_28a8_fc42_ac4b_b6ae2672cb88 2ac8d08a_6c80_ae3f_d4aa_e140740ac030["codegenValue()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 2ac8d08a_6c80_ae3f_d4aa_e140740ac030 686d679d_ced1_e9e0_39e5_1bf6e2f10dae["codegenArgument()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 686d679d_ced1_e9e0_39e5_1bf6e2f10dae 9cbd2355_05cd_5bbd_253f_7aeb4f947484["getHookKind()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 9cbd2355_05cd_5bbd_253f_7aeb4f947484 8b08b5b0_dece_e091_e968_4abdcd51cf05["createCallExpression()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 8b08b5b0_dece_e091_e968_4abdcd51cf05 d2920090_42bc_7919_897f_42680a08ace6["codegenInstructionValueToExpression()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| d2920090_42bc_7919_897f_42680a08ace6 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e a11bc4aa_cf2e_833d_d17b_0c1eefd2a759["codegenObjectPropertyKey()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| a11bc4aa_cf2e_833d_d17b_0c1eefd2a759 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 9d06bb9d_27c1_2f15_be7c_0fe428122d2d["buildReactiveFunction()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| 9d06bb9d_27c1_2f15_be7c_0fe428122d2d cc29904c_66f3_5155_9ed7_837866d52047["codegenReactiveFunction()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| cc29904c_66f3_5155_9ed7_837866d52047 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"] d8edf87e_ea78_c9d0_b5c9_13d68891efec -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6 style d8edf87e_ea78_c9d0_b5c9_13d68891efec fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts lines 1708–2327
function codegenInstructionValue(
cx: Context,
instrValue: ReactiveValue,
): t.Expression | t.JSXText {
let value: t.Expression | t.JSXText;
switch (instrValue.kind) {
case 'ArrayExpression': {
const elements = instrValue.elements.map(element => {
if (element.kind === 'Identifier') {
return codegenPlaceToExpression(cx, element);
} else if (element.kind === 'Spread') {
return t.spreadElement(codegenPlaceToExpression(cx, element.place));
} else {
return null;
}
});
value = t.arrayExpression(elements);
break;
}
case 'BinaryExpression': {
const left = codegenPlaceToExpression(cx, instrValue.left);
const right = codegenPlaceToExpression(cx, instrValue.right);
value = createBinaryExpression(
instrValue.loc,
instrValue.operator,
left,
right,
);
break;
}
case 'UnaryExpression': {
value = t.unaryExpression(
instrValue.operator,
codegenPlaceToExpression(cx, instrValue.value),
);
break;
}
case 'Primitive': {
value = codegenValue(cx, instrValue.loc, instrValue.value);
break;
}
case 'CallExpression': {
if (cx.env.config.enableForest) {
const callee = codegenPlaceToExpression(cx, instrValue.callee);
const args = instrValue.args.map(arg => codegenArgument(cx, arg));
value = t.callExpression(callee, args);
if (instrValue.typeArguments != null) {
value.typeArguments = t.typeParameterInstantiation(
instrValue.typeArguments,
);
}
break;
}
const isHook = getHookKind(cx.env, instrValue.callee.identifier) != null;
const callee = codegenPlaceToExpression(cx, instrValue.callee);
const args = instrValue.args.map(arg => codegenArgument(cx, arg));
value = createCallExpression(
cx.env,
callee,
args,
instrValue.loc,
isHook,
);
break;
}
case 'OptionalExpression': {
const optionalValue = codegenInstructionValueToExpression(
cx,
instrValue.value,
);
switch (optionalValue.type) {
case 'OptionalCallExpression':
case 'CallExpression': {
CompilerError.invariant(t.isExpression(optionalValue.callee), {
reason: 'v8 intrinsics are validated during lowering',
loc: optionalValue.callee.loc ?? GeneratedSource,
});
value = t.optionalCallExpression(
optionalValue.callee,
optionalValue.arguments,
instrValue.optional,
Domain
Subdomains
Defined In
Calls
- assertExhaustive()
- buildReactiveFunction()
- codegenArgument()
- codegenBlockNoReset()
- codegenInstructionValueToExpression()
- codegenJsxAttribute()
- codegenJsxElement()
- codegenJsxFbtChildElement()
- codegenLValue()
- codegenObjectPropertyKey()
- codegenPlaceToExpression()
- codegenReactiveFunction()
- codegenValue()
- convertMemberExpressionToJsx()
- createCallExpression()
- getHookKind()
- invariant()
- push()
- unwrap()
Source
Frequently Asked Questions
What does codegenInstructionValue() do?
codegenInstructionValue() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts.
Where is codegenInstructionValue() defined?
codegenInstructionValue() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts at line 1708.
What does codegenInstructionValue() call?
codegenInstructionValue() calls 19 function(s): assertExhaustive, buildReactiveFunction, codegenArgument, codegenBlockNoReset, codegenInstructionValueToExpression, codegenJsxAttribute, codegenJsxElement, codegenJsxFbtChildElement, and 11 more.
What calls codegenInstructionValue()?
codegenInstructionValue() is called by 2 function(s): codegenInstructionNullable, codegenInstructionValueToExpression.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free