Home / Function/ codegenInstruction() — react Function Reference

codegenInstruction() — react Function Reference

Architecture documentation for the codegenInstruction() function in CodegenReactiveFunction.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  e98029e7_d319_5eee_1233_4a0434b62d22["codegenInstruction()"]
  dc7f10c2_c914_a162_d02b_a10a15c64a5f["CodegenReactiveFunction.ts"]
  e98029e7_d319_5eee_1233_4a0434b62d22 -->|defined in| dc7f10c2_c914_a162_d02b_a10a15c64a5f
  c65f3ebd_fe8f_602d_b885_bc79e6e81b1d["codegenInstructionNullable()"]
  c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| e98029e7_d319_5eee_1233_4a0434b62d22
  953c4efc_05c3_e0ec_8bb2_341bc0c35066["convertValueToExpression()"]
  e98029e7_d319_5eee_1233_4a0434b62d22 -->|calls| 953c4efc_05c3_e0ec_8bb2_341bc0c35066
  43b28878_9b1d_6aeb_0d77_25080004044d["hasDeclared()"]
  e98029e7_d319_5eee_1233_4a0434b62d22 -->|calls| 43b28878_9b1d_6aeb_0d77_25080004044d
  9bb6f6d9_ff05_0f27_1a27_bc67145db7ba["convertIdentifier()"]
  e98029e7_d319_5eee_1233_4a0434b62d22 -->|calls| 9bb6f6d9_ff05_0f27_1a27_bc67145db7ba
  6a903108_0a0b_6e52_019e_0b534b909b09["createVariableDeclarator()"]
  e98029e7_d319_5eee_1233_4a0434b62d22 -->|calls| 6a903108_0a0b_6e52_019e_0b534b909b09
  style e98029e7_d319_5eee_1233_4a0434b62d22 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts lines 1654–1689

function codegenInstruction(
  cx: Context,
  instr: ReactiveInstruction,
  value: t.Expression | t.JSXText,
): t.Statement {
  if (t.isStatement(value)) {
    return value;
  }
  if (instr.lvalue === null) {
    return t.expressionStatement(convertValueToExpression(value));
  }
  if (instr.lvalue.identifier.name === null) {
    // temporary
    cx.temp.set(instr.lvalue.identifier.declarationId, value);
    return t.emptyStatement();
  } else {
    const expressionValue = convertValueToExpression(value);
    if (cx.hasDeclared(instr.lvalue.identifier)) {
      return createExpressionStatement(
        instr.loc,
        t.assignmentExpression(
          '=',
          convertIdentifier(instr.lvalue.identifier),
          expressionValue,
        ),
      );
    } else {
      return createVariableDeclaration(instr.loc, 'const', [
        createVariableDeclarator(
          convertIdentifier(instr.lvalue.identifier),
          expressionValue,
        ),
      ]);
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does codegenInstruction() do?
codegenInstruction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts.
Where is codegenInstruction() defined?
codegenInstruction() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts at line 1654.
What does codegenInstruction() call?
codegenInstruction() calls 4 function(s): convertIdentifier, convertValueToExpression, createVariableDeclarator, hasDeclared.
What calls codegenInstruction()?
codegenInstruction() is called by 1 function(s): codegenInstructionNullable.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free