Home / File/ InferReactiveScopeVariables.ts — react Source File

InferReactiveScopeVariables.ts — react Source File

Architecture documentation for InferReactiveScopeVariables.ts, a typescript file in the react codebase. 20 imports, 6 dependents.

File typescript BabelCompiler Validation 20 imports 6 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  f041318d_301f_daad_4198_91d141b3039d["InferReactiveScopeVariables.ts"]
  0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"]
  f041318d_301f_daad_4198_91d141b3039d --> 0423f759_97e0_9101_4634_ed555abc5ca9
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  f041318d_301f_daad_4198_91d141b3039d --> 18a78965_f593_105b_e5e8_07001321c2ec
  bf1aef24_2e0f_0adb_12d8_9e5ba8245644["DeclarationId"]
  f041318d_301f_daad_4198_91d141b3039d --> bf1aef24_2e0f_0adb_12d8_9e5ba8245644
  9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"]
  f041318d_301f_daad_4198_91d141b3039d --> 9241c5c1_a9a7_17bc_e41c_e967225008dd
  bd003dbd_e691_524b_0cf4_50e080ffea94["Identifier"]
  f041318d_301f_daad_4198_91d141b3039d --> bd003dbd_e691_524b_0cf4_50e080ffea94
  02d16d8e_0a17_fa6f_eeef_ee0c7d25bd36["Instruction"]
  f041318d_301f_daad_4198_91d141b3039d --> 02d16d8e_0a17_fa6f_eeef_ee0c7d25bd36
  23767d65_9554_fcd2_f2aa_7de7634389f9["InstructionId"]
  f041318d_301f_daad_4198_91d141b3039d --> 23767d65_9554_fcd2_f2aa_7de7634389f9
  60ce9143_a09b_64a1_ee02_3366e85369eb["MutableRange"]
  f041318d_301f_daad_4198_91d141b3039d --> 60ce9143_a09b_64a1_ee02_3366e85369eb
  c7aaa235_c19e_3530_31c2_911f38eed3e0["Place"]
  f041318d_301f_daad_4198_91d141b3039d --> c7aaa235_c19e_3530_31c2_911f38eed3e0
  ca9a6820_460e_0b15_8169_3aa4c6503770["ReactiveScope"]
  f041318d_301f_daad_4198_91d141b3039d --> ca9a6820_460e_0b15_8169_3aa4c6503770
  d0270ab6_a621_bd55_a1b9_a5cad8b406b2["makeInstructionId"]
  f041318d_301f_daad_4198_91d141b3039d --> d0270ab6_a621_bd55_a1b9_a5cad8b406b2
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  f041318d_301f_daad_4198_91d141b3039d --> 2f3caf55_cc64_415c_55dd_9771ba7dc210
  f4ce4a75_9bb6_f3be_c3c6_eb60cb87ce0e["doesPatternContainSpreadElement"]
  f041318d_301f_daad_4198_91d141b3039d --> f4ce4a75_9bb6_f3be_c3c6_eb60cb87ce0e
  ccace1c3_85b7_a05e_c2a5_7eff8b3422ed["eachInstructionOperand"]
  f041318d_301f_daad_4198_91d141b3039d --> ccace1c3_85b7_a05e_c2a5_7eff8b3422ed
  style f041318d_301f_daad_4198_91d141b3039d 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, SourceLocation} from '..';
import {Environment} from '../HIR';
import {
  DeclarationId,
  GeneratedSource,
  HIRFunction,
  Identifier,
  Instruction,
  InstructionId,
  MutableRange,
  Place,
  ReactiveScope,
  makeInstructionId,
} from '../HIR/HIR';
import {
  doesPatternContainSpreadElement,
  eachInstructionOperand,
  eachPatternOperand,
} from '../HIR/visitors';
import DisjointSet from '../Utils/DisjointSet';
import {assertExhaustive} from '../Utils/utils';

/*
 * Note: this is the 1st of 4 passes that determine how to break a function into discrete
 * reactive scopes (independently memoizeable units of code):
 * 1. InferReactiveScopeVariables (this pass, on HIR) determines operands that mutate
 *     together and assigns them a unique reactive scope.
 * 2. AlignReactiveScopesToBlockScopes (on ReactiveFunction) aligns reactive scopes
 *     to block scopes.
 * 3. MergeOverlappingReactiveScopes (on ReactiveFunction) ensures that reactive
 *     scopes do not overlap, merging any such scopes.
 * 4. BuildReactiveBlocks (on ReactiveFunction) groups the statements for each scope into
 *     a ReactiveScopeBlock.
 *
 * For each mutable variable, infers a reactive scope which will construct that
 * variable. Variables that co-mutate are assigned to the same reactive scope.
 * This pass does *not* infer the set of instructions necessary to compute each
 * variable/scope, only the set of variables that will be computed by each scope.
 *
 * Examples:
 * ```javascript
 * // Mutable arguments
 * let x = {};
 * let y = [];
 * foo(x, y); // both args mutable, could alias each other
 * y.push(x); // y is part of callee, counts as operand
 *
 * let z = {};
 * y.push(z);
 *
 * // Mutable assignment
 * let x = {};
 * let y = [];
// ... (337 more lines)

Domain

Subdomains

Frequently Asked Questions

What does InferReactiveScopeVariables.ts do?
InferReactiveScopeVariables.ts is a source file in the react codebase, written in typescript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in InferReactiveScopeVariables.ts?
InferReactiveScopeVariables.ts defines 6 function(s): findDisjointMutableValues, inRange, inferReactiveScopeVariables, isMutable, mayAllocate, mergeLocation.
What does InferReactiveScopeVariables.ts depend on?
InferReactiveScopeVariables.ts imports 20 module(s): .., DeclarationId, DisjointSet, DisjointSet.ts, HIR.ts, HIRFunction, Identifier, Instruction, and 12 more.
What files import InferReactiveScopeVariables.ts?
InferReactiveScopeVariables.ts is imported by 6 file(s): CollectHoistablePropertyLoads.ts, InferReactivePlaces.ts, MergeOverlappingReactiveScopesHIR.ts, ValidateMemoizedEffectDependencies.ts, ValidateNoDerivedComputationsInEffects_exp.ts, ValidateNoSetStateInEffects.ts.
Where is InferReactiveScopeVariables.ts in the architecture?
InferReactiveScopeVariables.ts is located at compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/InferReactiveScopeVariables.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes).

Analyze Your Own Codebase

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

Try Supermodel Free