Home / Function/ mapTerminalOperands() — react Function Reference

mapTerminalOperands() — react Function Reference

Architecture documentation for the mapTerminalOperands() function in visitors.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  71641405_57a3_9311_7d44_d8f827acb5dd["mapTerminalOperands()"]
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  71641405_57a3_9311_7d44_d8f827acb5dd -->|defined in| 2f3caf55_cc64_415c_55dd_9771ba7dc210
  876d58c8_bfce_a9d8_22c0_b40cc7e22553["inlineJsxTransform()"]
  876d58c8_bfce_a9d8_22c0_b40cc7e22553 -->|calls| 71641405_57a3_9311_7d44_d8f827acb5dd
  8ec30eb2_4622_378f_f538_3070f7a38fae["enterSSAImpl()"]
  8ec30eb2_4622_378f_f538_3070f7a38fae -->|calls| 71641405_57a3_9311_7d44_d8f827acb5dd
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"]
  71641405_57a3_9311_7d44_d8f827acb5dd -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6
  style 71641405_57a3_9311_7d44_d8f827acb5dd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts lines 1112–1174

export function mapTerminalOperands(
  terminal: Terminal,
  fn: (place: Place) => Place,
): void {
  switch (terminal.kind) {
    case 'if': {
      terminal.test = fn(terminal.test);
      break;
    }
    case 'branch': {
      terminal.test = fn(terminal.test);
      break;
    }
    case 'switch': {
      terminal.test = fn(terminal.test);
      for (const case_ of terminal.cases) {
        if (case_.test === null) {
          continue;
        }
        case_.test = fn(case_.test);
      }
      break;
    }
    case 'return':
    case 'throw': {
      terminal.value = fn(terminal.value);
      break;
    }
    case 'try': {
      if (terminal.handlerBinding !== null) {
        terminal.handlerBinding = fn(terminal.handlerBinding);
      } else {
        terminal.handlerBinding = null;
      }
      break;
    }
    case 'maybe-throw':
    case 'sequence':
    case 'label':
    case 'optional':
    case 'ternary':
    case 'logical':
    case 'do-while':
    case 'while':
    case 'for':
    case 'for-of':
    case 'for-in':
    case 'goto':
    case 'unreachable':
    case 'unsupported':
    case 'scope':
    case 'pruned-scope': {
      // no-op
      break;
    }
    default: {
      assertExhaustive(
        terminal,
        `Unexpected terminal kind \`${(terminal as any).kind}\``,
      );
    }
  }
}

Subdomains

Frequently Asked Questions

What does mapTerminalOperands() do?
mapTerminalOperands() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts.
Where is mapTerminalOperands() defined?
mapTerminalOperands() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts at line 1112.
What does mapTerminalOperands() call?
mapTerminalOperands() calls 1 function(s): assertExhaustive.
What calls mapTerminalOperands()?
mapTerminalOperands() is called by 2 function(s): enterSSAImpl, inlineJsxTransform.

Analyze Your Own Codebase

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

Try Supermodel Free