Home / Function/ loop() — react Function Reference

loop() — react Function Reference

Architecture documentation for the loop() function in HIRBuilder.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d1286404_312e_5b54_3bf3_d09a954c68eb["loop()"]
  d1b85268_f4cd_bc3c_7ba0_ee15dcc8a845["HIRBuilder"]
  d1286404_312e_5b54_3bf3_d09a954c68eb -->|defined in| d1b85268_f4cd_bc3c_7ba0_ee15dcc8a845
  c01b12bd_811d_9f90_f641_fac8e518dbb7["lowerStatement()"]
  c01b12bd_811d_9f90_f641_fac8e518dbb7 -->|calls| d1286404_312e_5b54_3bf3_d09a954c68eb
  53244187_914c_cc90_5880_7bfc1fc9c0bb["push()"]
  d1286404_312e_5b54_3bf3_d09a954c68eb -->|calls| 53244187_914c_cc90_5880_7bfc1fc9c0bb
  041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"]
  d1286404_312e_5b54_3bf3_d09a954c68eb -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e
  style d1286404_312e_5b54_3bf3_d09a954c68eb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts lines 540–568

  loop<T>(
    label: string | null,
    // block of the loop body. "continue" jumps here.
    continueBlock: BlockId,
    // block following the loop. "break" jumps here.
    breakBlock: BlockId,
    fn: () => T,
  ): T {
    this.#scopes.push({
      kind: 'loop',
      label,
      continueBlock,
      breakBlock,
    });
    const value = fn();
    const last = this.#scopes.pop();
    CompilerError.invariant(
      last != null &&
        last.kind === 'loop' &&
        last.label === label &&
        last.continueBlock === continueBlock &&
        last.breakBlock === breakBlock,
      {
        reason: 'Mismatched loops',
        loc: GeneratedSource,
      },
    );
    return value;
  }

Subdomains

Called By

Frequently Asked Questions

What does loop() do?
loop() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts.
Where is loop() defined?
loop() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts at line 540.
What does loop() call?
loop() calls 2 function(s): invariant, push.
What calls loop()?
loop() is called by 1 function(s): lowerStatement.

Analyze Your Own Codebase

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

Try Supermodel Free