Home / File/ BuildReactiveScopeTerminalsHIR.ts — react Source File

BuildReactiveScopeTerminalsHIR.ts — react Source File

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

File typescript MIRInfrastructure HIR 22 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70["BuildReactiveScopeTerminalsHIR.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> e96f281e_f381_272d_2359_3e6a091c9a1d
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> e51fd0d2_bb38_cc97_7763_efe37f300a47
  5dff208f_71b7_72c1_b78a_03be9b621b2a["AssertValidBlockNesting.ts"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 5dff208f_71b7_72c1_b78a_03be9b621b2a
  ad41542d_7277_a7c4_02f9_ea27be6345d4["getScopes"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> ad41542d_7277_a7c4_02f9_ea27be6345d4
  170cf454_aca5_0b9b_0991_4b81319b731b["recursivelyTraverseItems"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 170cf454_aca5_0b9b_0991_4b81319b731b
  1b971013_8a90_0d8d_1fcc_f31581cd66aa["Environment.ts"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 1b971013_8a90_0d8d_1fcc_f31581cd66aa
  cba0c8a2_0db5_48e2_0d19_b2c6a46799e8["Environment"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> cba0c8a2_0db5_48e2_0d19_b2c6a46799e8
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 18a78965_f593_105b_e5e8_07001321c2ec
  5b3acd48_6f52_d332_a26f_b7cb0f74b86e["BasicBlock"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 5b3acd48_6f52_d332_a26f_b7cb0f74b86e
  4a73a9b9_07eb_502f_14c1_2f045ba2666c["BlockId"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 4a73a9b9_07eb_502f_14c1_2f045ba2666c
  3c62e65d_5e12_9a70_40cc_041bda131d9c["GotoTerminal"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 3c62e65d_5e12_9a70_40cc_041bda131d9c
  b520037e_e135_2bd9_f501_1fe9a8324ce5["GotoVariant"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> b520037e_e135_2bd9_f501_1fe9a8324ce5
  9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 9241c5c1_a9a7_17bc_e41c_e967225008dd
  23767d65_9554_fcd2_f2aa_7de7634389f9["InstructionId"]
  779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 --> 23767d65_9554_fcd2_f2aa_7de7634389f9
  style 779d40ec_03b1_7ad7_ef48_9ccec3c3bf70 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 {getScopes, recursivelyTraverseItems} from './AssertValidBlockNesting';
import {Environment} from './Environment';
import {
  BasicBlock,
  BlockId,
  GeneratedSource,
  GotoTerminal,
  GotoVariant,
  HIRFunction,
  InstructionId,
  ReactiveScope,
  ReactiveScopeTerminal,
  ScopeId,
} from './HIR';
import {
  fixScopeAndIdentifierRanges,
  markInstructionIds,
  markPredecessors,
  reversePostorderBlocks,
} from './HIRBuilder';

/**
 * This pass assumes that all program blocks are properly nested with respect to fallthroughs
 * (e.g. a valid javascript AST).
 * Given a function whose reactive scope ranges have been correctly aligned and merged,
 * this pass rewrites blocks to introduce ReactiveScopeTerminals and their fallthrough blocks.
 * e.g.
 * ```js
 * // source
 * [0] ...
 * [1] const x = [];  ⌝ scope range
 * [2] if (cond) {    |
 * [3]  x.push(a);    |
 *     }              |
 * [4] x.push(b);     ⌟
 * [5] ...
 *
 * // before this pass
 * bb0:
 *  [0]
 *  [1]
 *  [2]
 *  If ($2) then bb1 else bb2 (fallthrough=bb2)
 * bb1:
 *  [3]
 *  Goto bb2
 * bb2:
 *  [4]
 *  [5]
 *
 * // after this pass
 * bb0:
// ... (252 more lines)

Subdomains

Frequently Asked Questions

What does BuildReactiveScopeTerminalsHIR.ts do?
BuildReactiveScopeTerminalsHIR.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 BuildReactiveScopeTerminalsHIR.ts?
BuildReactiveScopeTerminalsHIR.ts defines 4 function(s): buildReactiveScopeTerminalsHIR, handleRewrite, pushEndScopeTerminal, pushStartScopeTerminal.
What does BuildReactiveScopeTerminalsHIR.ts depend on?
BuildReactiveScopeTerminalsHIR.ts imports 22 module(s): AssertValidBlockNesting.ts, BasicBlock, BlockId, CompilerError, CompilerError.ts, Environment, Environment.ts, GotoTerminal, and 14 more.
Where is BuildReactiveScopeTerminalsHIR.ts in the architecture?
BuildReactiveScopeTerminalsHIR.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/BuildReactiveScopeTerminalsHIR.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