Home / Function/ lowerExpression() — react Function Reference

lowerExpression() — react Function Reference

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

Function typescript MIRInfrastructure HIR calls 31 called by 1

Entity Profile

Dependency Diagram

graph TD
  ace1177a_10b2_b870_31fd_da4aa845554c["lowerExpression()"]
  e04c04d6_37a7_1dc3_7fae_7d07660d0af9["BuildHIR.ts"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|defined in| e04c04d6_37a7_1dc3_7fae_7d07660d0af9
  5bae3f87_1b76_e568_9b44_1d2fb59f73d8["lowerExpressionToTemporary()"]
  5bae3f87_1b76_e568_9b44_1d2fb59f73d8 -->|calls| ace1177a_10b2_b870_31fd_da4aa845554c
  b210ff8f_3273_1b70_4f00_b08cc41fd3dd["lowerIdentifier()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| b210ff8f_3273_1b70_4f00_b08cc41fd3dd
  ed6d70a7_397f_1137_1a2e_8b9092747144["getLoadKind()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| ed6d70a7_397f_1137_1a2e_8b9092747144
  2e161d82_7d7b_025c_6019_853bed0b8f64["lowerObjectPropertyKey()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| 2e161d82_7d7b_025c_6019_853bed0b8f64
  5bae3f87_1b76_e568_9b44_1d2fb59f73d8["lowerExpressionToTemporary()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| 5bae3f87_1b76_e568_9b44_1d2fb59f73d8
  0dc9964a_90d6_36ea_5cbb_0afd21422799["lowerObjectMethod()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| 0dc9964a_90d6_36ea_5cbb_0afd21422799
  f1f0c182_09ad_b29e_b1ca_56f10046adff["lowerValueToTemporary()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| f1f0c182_09ad_b29e_b1ca_56f10046adff
  a1ea0998_17ee_ee03_aad6_a8367893b004["lowerArguments()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| a1ea0998_17ee_ee03_aad6_a8367893b004
  e401a324_13b9_af8a_12c7_b731c9f220a3["lowerOptionalCallExpression()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| e401a324_13b9_af8a_12c7_b731c9f220a3
  d3430316_6bb4_9d91_4539_1bff5c189f83["lowerMemberExpression()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| d3430316_6bb4_9d91_4539_1bff5c189f83
  2a23449a_1dec_0ba3_8f5a_0e9e83d42add["reserve()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| 2a23449a_1dec_0ba3_8f5a_0e9e83d42add
  012a7acd_73d1_2699_77e8_481232bb47c8["currentBlockKind()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| 012a7acd_73d1_2699_77e8_481232bb47c8
  147a0e7f_dab2_6a99_0c59_2eb8b07f70d5["buildTemporaryPlace()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| 147a0e7f_dab2_6a99_0c59_2eb8b07f70d5
  3db1e7ce_1c6f_24e2_3cbb_86c02c29d285["enter()"]
  ace1177a_10b2_b870_31fd_da4aa845554c -->|calls| 3db1e7ce_1c6f_24e2_3cbb_86c02c29d285
  style ace1177a_10b2_b870_31fd_da4aa845554c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts lines 1545–2675

function lowerExpression(
  builder: HIRBuilder,
  exprPath: NodePath<t.Expression>,
): InstructionValue {
  const exprNode = exprPath.node;
  const exprLoc = exprNode.loc ?? GeneratedSource;
  switch (exprNode.type) {
    case 'Identifier': {
      const expr = exprPath as NodePath<t.Identifier>;
      const place = lowerIdentifier(builder, expr);
      return {
        kind: getLoadKind(builder, expr),
        place,
        loc: exprLoc,
      };
    }
    case 'NullLiteral': {
      return {
        kind: 'Primitive',
        value: null,
        loc: exprLoc,
      };
    }
    case 'BooleanLiteral':
    case 'NumericLiteral':
    case 'StringLiteral': {
      const expr = exprPath as NodePath<
        t.StringLiteral | t.BooleanLiteral | t.NumericLiteral
      >;
      const value = expr.node.value;
      return {
        kind: 'Primitive',
        value,
        loc: exprLoc,
      };
    }
    case 'ObjectExpression': {
      const expr = exprPath as NodePath<t.ObjectExpression>;
      const propertyPaths = expr.get('properties');
      const properties: Array<ObjectProperty | SpreadPattern> = [];
      for (const propertyPath of propertyPaths) {
        if (propertyPath.isObjectProperty()) {
          const loweredKey = lowerObjectPropertyKey(builder, propertyPath);
          if (!loweredKey) {
            continue;
          }
          const valuePath = propertyPath.get('value');
          if (!valuePath.isExpression()) {
            builder.errors.push({
              reason: `(BuildHIR::lowerExpression) Handle ${valuePath.type} values in ObjectExpression`,
              category: ErrorCategory.Todo,
              loc: valuePath.node.loc ?? null,
              suggestions: null,
            });
            continue;
          }
          const value = lowerExpressionToTemporary(builder, valuePath);
          properties.push({
            kind: 'ObjectProperty',
            type: 'property',
            place: value,
            key: loweredKey,
          });
        } else if (propertyPath.isSpreadElement()) {
          const place = lowerExpressionToTemporary(
            builder,
            propertyPath.get('argument'),
          );
          properties.push({
            kind: 'Spread',
            place,
          });
        } else if (propertyPath.isObjectMethod()) {
          if (propertyPath.node.kind !== 'method') {
            builder.errors.push({
              reason: `(BuildHIR::lowerExpression) Handle ${propertyPath.node.kind} functions in ObjectExpression`,
              category: ErrorCategory.Todo,
              loc: propertyPath.node.loc ?? null,
              suggestions: null,
            });
            continue;

Subdomains

Frequently Asked Questions

What does lowerExpression() do?
lowerExpression() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts.
Where is lowerExpression() defined?
lowerExpression() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts at line 1545.
What does lowerExpression() call?
lowerExpression() calls 31 function(s): buildTemporaryPlace, currentBlockKind, enter, getLoadKind, getStoreKind, hasAnyErrors, invariant, isContextIdentifier, and 23 more.
What calls lowerExpression()?
lowerExpression() is called by 1 function(s): lowerExpressionToTemporary.

Analyze Your Own Codebase

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

Try Supermodel Free