Home / File/ AssertValidBlockNesting.ts — react Source File

AssertValidBlockNesting.ts — react Source File

Architecture documentation for AssertValidBlockNesting.ts, a typescript file in the react codebase. 13 imports, 1 dependents.

File typescript MIRInfrastructure HIR 13 imports 1 dependents 5 functions

Entity Profile

Dependency Diagram

graph LR
  5dff208f_71b7_72c1_b78a_03be9b621b2a["AssertValidBlockNesting.ts"]
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 18a78965_f593_105b_e5e8_07001321c2ec
  4a73a9b9_07eb_502f_14c1_2f045ba2666c["BlockId"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 4a73a9b9_07eb_502f_14c1_2f045ba2666c
  9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 9241c5c1_a9a7_17bc_e41c_e967225008dd
  60ce9143_a09b_64a1_ee02_3366e85369eb["MutableRange"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 60ce9143_a09b_64a1_ee02_3366e85369eb
  c7aaa235_c19e_3530_31c2_911f38eed3e0["Place"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> c7aaa235_c19e_3530_31c2_911f38eed3e0
  ca9a6820_460e_0b15_8169_3aa4c6503770["ReactiveScope"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> ca9a6820_460e_0b15_8169_3aa4c6503770
  2000a5ea_d4ee_1737_10c8_f1b98f24004e["ScopeId"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 2000a5ea_d4ee_1737_10c8_f1b98f24004e
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 2f3caf55_cc64_415c_55dd_9771ba7dc210
  10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 10043bf1_f7ee_9ed9_307a_fe3edfd02b09
  ccace1c3_85b7_a05e_c2a5_7eff8b3422ed["eachInstructionOperand"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> ccace1c3_85b7_a05e_c2a5_7eff8b3422ed
  41232a25_deb6_6e83_05a8_ae9f961656f7["eachTerminalOperand"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 41232a25_deb6_6e83_05a8_ae9f961656f7
  127c19ef_021e_5644_a84e_da0d0ed84999["terminalFallthrough"]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 127c19ef_021e_5644_a84e_da0d0ed84999
  2ed45bcd_6c82_3ccd_0e20_fa96b5111055[".."]
  5dff208f_71b7_72c1_b78a_03be9b621b2a --> 2ed45bcd_6c82_3ccd_0e20_fa96b5111055
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70["BuildReactiveScopeTerminalsHIR.ts"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 5dff208f_71b7_72c1_b78a_03be9b621b2a
  style 5dff208f_71b7_72c1_b78a_03be9b621b2a 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 '..';
import {
  BlockId,
  GeneratedSource,
  HIRFunction,
  MutableRange,
  Place,
  ReactiveScope,
  ScopeId,
} from './HIR';
import {
  eachInstructionLValue,
  eachInstructionOperand,
  eachTerminalOperand,
  terminalFallthrough,
} from './visitors';

/**
 * This pass asserts that program blocks and scopes properly form a tree hierarchy
 * with respect to block and scope ranges. In other words, two ranges must either
 * disjoint or nested.
 *
 * ProgramBlockSubtree = subtree of basic blocks between a terminal and its fallthrough
 * (e.g. continuation in the source AST). This spans every instruction contained within
 * the source AST subtree representing the terminal.
 *
 * In this example, there is a single ProgramBlockSubtree, which spans instructions 1:5
 * ```js
 * function Foo() {
 *   [0] a;
 *   [1] if (cond) {
 *   [2]   b;
 *   [3] } else {
 *   [4]   c;
 *       }
 *   [5] d;
 * }
 * ```
 *
 * Scope = reactive scope whose range has been correctly aligned and merged.
 */
type Block =
  | ({
      kind: 'ProgramBlockSubtree';
      id: BlockId;
    } & MutableRange)
  | ({
      kind: 'Scope';
      id: ScopeId;
    } & MutableRange);

export function getScopes(fn: HIRFunction): Set<ReactiveScope> {
  const scopes: Set<ReactiveScope> = new Set();
// ... (119 more lines)

Subdomains

Types

Frequently Asked Questions

What does AssertValidBlockNesting.ts do?
AssertValidBlockNesting.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 AssertValidBlockNesting.ts?
AssertValidBlockNesting.ts defines 5 function(s): assertValidBlockNesting, getScopes, no_op, rangePreOrderComparator, recursivelyTraverseItems.
What does AssertValidBlockNesting.ts depend on?
AssertValidBlockNesting.ts imports 13 module(s): .., BlockId, HIR.ts, HIRFunction, MutableRange, Place, ReactiveScope, ScopeId, and 5 more.
What files import AssertValidBlockNesting.ts?
AssertValidBlockNesting.ts is imported by 1 file(s): BuildReactiveScopeTerminalsHIR.ts.
Where is AssertValidBlockNesting.ts in the architecture?
AssertValidBlockNesting.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/AssertValidBlockNesting.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