Home / Function/ lowerFunction() — react Function Reference

lowerFunction() — react Function Reference

Architecture documentation for the lowerFunction() function in BuildHIR.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  535369af_370f_d1a4_e72e_56482eceef72["lowerFunction()"]
  e04c04d6_37a7_1dc3_7fae_7d07660d0af9["BuildHIR.ts"]
  535369af_370f_d1a4_e72e_56482eceef72 -->|defined in| e04c04d6_37a7_1dc3_7fae_7d07660d0af9
  0dc9964a_90d6_36ea_5cbb_0afd21422799["lowerObjectMethod()"]
  0dc9964a_90d6_36ea_5cbb_0afd21422799 -->|calls| 535369af_370f_d1a4_e72e_56482eceef72
  2e9602e6_59e9_f811_a650_6a66577561c4["lowerFunctionToValue()"]
  2e9602e6_59e9_f811_a650_6a66577561c4 -->|calls| 535369af_370f_d1a4_e72e_56482eceef72
  de018292_621c_1061_1e34_80ea74ce2c88["gatherCapturedContext()"]
  535369af_370f_d1a4_e72e_56482eceef72 -->|calls| de018292_621c_1061_1e34_80ea74ce2c88
  f214c28b_2f6d_b5a3_71e1_9a69d9b50455["lower()"]
  535369af_370f_d1a4_e72e_56482eceef72 -->|calls| f214c28b_2f6d_b5a3_71e1_9a69d9b50455
  7930cad6_ab99_ae3b_5cac_03042fe5727b["merge()"]
  535369af_370f_d1a4_e72e_56482eceef72 -->|calls| 7930cad6_ab99_ae3b_5cac_03042fe5727b
  f0a04cba_f197_dc31_243c_26243c07a3a4["isErr()"]
  535369af_370f_d1a4_e72e_56482eceef72 -->|calls| f0a04cba_f197_dc31_243c_26243c07a3a4
  7dd8eefb_2237_6426_9d5d_a2c0267dc003["unwrapErr()"]
  535369af_370f_d1a4_e72e_56482eceef72 -->|calls| 7dd8eefb_2237_6426_9d5d_a2c0267dc003
  5228ee8c_dc7c_d859_3f41_614fd9c00374["unwrap()"]
  535369af_370f_d1a4_e72e_56482eceef72 -->|calls| 5228ee8c_dc7c_d859_3f41_614fd9c00374
  style 535369af_370f_d1a4_e72e_56482eceef72 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts lines 3484–3520

function lowerFunction(
  builder: HIRBuilder,
  expr: NodePath<
    | t.FunctionExpression
    | t.ArrowFunctionExpression
    | t.FunctionDeclaration
    | t.ObjectMethod
  >,
): LoweredFunction | null {
  const componentScope: Scope = builder.environment.parentFunction.scope;
  const capturedContext = gatherCapturedContext(expr, componentScope);

  /*
   * TODO(gsn): In the future, we could only pass in the context identifiers
   * that are actually used by this function and it's nested functions, rather
   * than all context identifiers.
   *
   * This isn't a problem in practice because use Babel's scope analysis to
   * identify the correct references.
   */
  const lowering = lower(
    expr,
    builder.environment,
    builder.bindings,
    new Map([...builder.context, ...capturedContext]),
  );
  let loweredFunc: HIRFunction;
  if (lowering.isErr()) {
    const functionErrors = lowering.unwrapErr();
    builder.errors.merge(functionErrors);
    return null;
  }
  loweredFunc = lowering.unwrap();
  return {
    func: loweredFunc,
  };
}

Subdomains

Frequently Asked Questions

What does lowerFunction() do?
lowerFunction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts.
Where is lowerFunction() defined?
lowerFunction() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts at line 3484.
What does lowerFunction() call?
lowerFunction() calls 6 function(s): gatherCapturedContext, isErr, lower, merge, unwrap, unwrapErr.
What calls lowerFunction()?
lowerFunction() is called by 2 function(s): lowerFunctionToValue, lowerObjectMethod.

Analyze Your Own Codebase

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

Try Supermodel Free