Home / File/ AssertTerminalBlocksExist.ts — react Source File

AssertTerminalBlocksExist.ts — react Source File

Architecture documentation for AssertTerminalBlocksExist.ts, a typescript file in the react codebase. 9 imports, 0 dependents.

File typescript MIRInfrastructure HIR 9 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  572aada9_286c_f6c1_f21b_7883e8a8a120["AssertTerminalBlocksExist.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> e96f281e_f381_272d_2359_3e6a091c9a1d
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> e51fd0d2_bb38_cc97_7763_efe37f300a47
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> 18a78965_f593_105b_e5e8_07001321c2ec
  9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> 9241c5c1_a9a7_17bc_e41c_e967225008dd
  6976a9ee_9d8e_4f16_3016_495f39aff2fd["PrintHIR.ts"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> 6976a9ee_9d8e_4f16_3016_495f39aff2fd
  809a0fbd_e458_a174_789b_dc2fd017231a["printTerminal"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> 809a0fbd_e458_a174_789b_dc2fd017231a
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> 2f3caf55_cc64_415c_55dd_9771ba7dc210
  d737cb4c_53f4_75b4_2d58_268e2f73fde4["eachTerminalSuccessor"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> d737cb4c_53f4_75b4_2d58_268e2f73fde4
  1e59d6f3_b074_b12f_86b8_b6d2fe62021a["mapTerminalSuccessors"]
  572aada9_286c_f6c1_f21b_7883e8a8a120 --> 1e59d6f3_b074_b12f_86b8_b6d2fe62021a
  style 572aada9_286c_f6c1_f21b_7883e8a8a120 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import {CompilerError} from '../CompilerError';
import {GeneratedSource, HIRFunction} from './HIR';
import {printTerminal} from './PrintHIR';
import {eachTerminalSuccessor, mapTerminalSuccessors} from './visitors';

export function assertTerminalSuccessorsExist(fn: HIRFunction): void {
  for (const [, block] of fn.body.blocks) {
    mapTerminalSuccessors(block.terminal, successor => {
      CompilerError.invariant(fn.body.blocks.has(successor), {
        reason: `Terminal successor references unknown block`,
        description: `Block bb${successor} does not exist for terminal '${printTerminal(
          block.terminal,
        )}'`,
        loc: (block.terminal as any).loc ?? GeneratedSource,
      });
      return successor;
    });
  }
}

export function assertTerminalPredsExist(fn: HIRFunction): void {
  for (const [, block] of fn.body.blocks) {
    for (const pred of block.preds) {
      const predBlock = fn.body.blocks.get(pred);
      CompilerError.invariant(predBlock != null, {
        reason: 'Expected predecessor block to exist',
        description: `Block ${block.id} references non-existent ${pred}`,
        loc: GeneratedSource,
      });
      CompilerError.invariant(
        [...eachTerminalSuccessor(predBlock.terminal)].includes(block.id),
        {
          reason: 'Terminal successor does not reference correct predecessor',
          description: `Block bb${block.id} has bb${predBlock.id} as a predecessor, but bb${predBlock.id}'s successors do not include bb${block.id}`,
          loc: GeneratedSource,
        },
      );
    }
  }
}

Subdomains

Frequently Asked Questions

What does AssertTerminalBlocksExist.ts do?
AssertTerminalBlocksExist.ts is a source file in the react codebase, written in typescript. It belongs to the MIRInfrastructure domain, HIR subdomain.
What functions are defined in AssertTerminalBlocksExist.ts?
AssertTerminalBlocksExist.ts defines 2 function(s): assertTerminalPredsExist, assertTerminalSuccessorsExist.
What does AssertTerminalBlocksExist.ts depend on?
AssertTerminalBlocksExist.ts imports 9 module(s): CompilerError, CompilerError.ts, HIR.ts, HIRFunction, PrintHIR.ts, eachTerminalSuccessor, mapTerminalSuccessors, printTerminal, and 1 more.
Where is AssertTerminalBlocksExist.ts in the architecture?
AssertTerminalBlocksExist.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/AssertTerminalBlocksExist.ts (domain: MIRInfrastructure, subdomain: HIR, directory: compiler/packages/babel-plugin-react-compiler/src/HIR).

Analyze Your Own Codebase

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

Try Supermodel Free