Home / File/ ValidateNoDerivedComputationsInEffects_exp.ts — react Source File

ValidateNoDerivedComputationsInEffects_exp.ts — react Source File

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

File typescript BabelCompiler Validation 13 imports 1 dependents 11 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  a38a9d1f_969c_8056_aa80_6cb5fedba226["ValidateNoDerivedComputationsInEffects_exp.ts"]
  494e3425_0b47_293a_1ea4_d4670b0fc0e7["Result.ts"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> 494e3425_0b47_293a_1ea4_d4670b0fc0e7
  7aace723_0ee1_cff5_b263_aec8e06dd79e["Result"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> 7aace723_0ee1_cff5_b263_aec8e06dd79e
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> e96f281e_f381_272d_2359_3e6a091c9a1d
  a2b91621_58d3_1d04_4663_00cd808f1034["ErrorCategory"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> a2b91621_58d3_1d04_4663_00cd808f1034
  0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> 0423f759_97e0_9101_4634_ed555abc5ca9
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> 2f3caf55_cc64_415c_55dd_9771ba7dc210
  10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> 10043bf1_f7ee_9ed9_307a_fe3edfd02b09
  ccace1c3_85b7_a05e_c2a5_7eff8b3422ed["eachInstructionOperand"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> ccace1c3_85b7_a05e_c2a5_7eff8b3422ed
  f041318d_301f_daad_4198_91d141b3039d["InferReactiveScopeVariables.ts"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> f041318d_301f_daad_4198_91d141b3039d
  11746e9a_2fdf_98bb_bb3c_a63d8b200df2["isMutable"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> 11746e9a_2fdf_98bb_bb3c_a63d8b200df2
  eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> eb9d33f9_42c1_205c_93e6_8e1365a31839
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> d7fde76c_4fd9_feb3_299b_798689f05bc6
  2ed45bcd_6c82_3ccd_0e20_fa96b5111055[".."]
  a38a9d1f_969c_8056_aa80_6cb5fedba226 --> 2ed45bcd_6c82_3ccd_0e20_fa96b5111055
  e3cfc07a_10c8_5dcd_e270_e8e14c29309b["Pipeline.ts"]
  e3cfc07a_10c8_5dcd_e270_e8e14c29309b --> a38a9d1f_969c_8056_aa80_6cb5fedba226
  style a38a9d1f_969c_8056_aa80_6cb5fedba226 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 {Result} from '../Utils/Result';
import {CompilerDiagnostic, CompilerError, Effect} from '..';
import {ErrorCategory} from '../CompilerError';
import {
  BlockId,
  FunctionExpression,
  HIRFunction,
  IdentifierId,
  isSetStateType,
  isUseEffectHookType,
  Place,
  CallExpression,
  Instruction,
  isUseStateType,
  BasicBlock,
  isUseRefType,
  SourceLocation,
  ArrayExpression,
} from '../HIR';
import {eachInstructionLValue, eachInstructionOperand} from '../HIR/visitors';
import {isMutable} from '../ReactiveScopes/InferReactiveScopeVariables';
import {assertExhaustive} from '../Utils/utils';

type TypeOfValue = 'ignored' | 'fromProps' | 'fromState' | 'fromPropsAndState';

type DerivationMetadata = {
  typeOfValue: TypeOfValue;
  place: Place;
  sourcesIds: Set<IdentifierId>;
  isStateSource: boolean;
};

type EffectMetadata = {
  effect: HIRFunction;
  dependencies: ArrayExpression;
};

type ValidationContext = {
  readonly functions: Map<IdentifierId, FunctionExpression>;
  readonly candidateDependencies: Map<IdentifierId, ArrayExpression>;
  readonly errors: CompilerError;
  readonly derivationCache: DerivationCache;
  readonly effectsCache: Map<IdentifierId, EffectMetadata>;
  readonly setStateLoads: Map<IdentifierId, IdentifierId | null>;
  readonly setStateUsages: Map<IdentifierId, Set<SourceLocation>>;
};

const MAX_FIXPOINT_ITERATIONS = 100;

class DerivationCache {
  hasChanges: boolean = false;
  cache: Map<IdentifierId, DerivationMetadata> = new Map();
  private previousCache: Map<IdentifierId, DerivationMetadata> | null = null;
// ... (783 more lines)

Domain

Subdomains

Classes

Frequently Asked Questions

What does ValidateNoDerivedComputationsInEffects_exp.ts do?
ValidateNoDerivedComputationsInEffects_exp.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 ValidateNoDerivedComputationsInEffects_exp.ts?
ValidateNoDerivedComputationsInEffects_exp.ts defines 11 function(s): buildTreeNode, getFnLocalDeps, getRootSetState, isNamedIdentifier, joinValue, maybeRecordSetState, recordInstructionDerivations, recordPhiDerivations, renderTree, validateEffect, and 1 more.
What does ValidateNoDerivedComputationsInEffects_exp.ts depend on?
ValidateNoDerivedComputationsInEffects_exp.ts imports 13 module(s): .., CompilerError.ts, ErrorCategory, InferReactiveScopeVariables.ts, Result, Result.ts, assertExhaustive, eachInstructionLValue, and 5 more.
What files import ValidateNoDerivedComputationsInEffects_exp.ts?
ValidateNoDerivedComputationsInEffects_exp.ts is imported by 1 file(s): Pipeline.ts.
Where is ValidateNoDerivedComputationsInEffects_exp.ts in the architecture?
ValidateNoDerivedComputationsInEffects_exp.ts is located at compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Validation).

Analyze Your Own Codebase

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

Try Supermodel Free