Home / File/ ExtractScopeDeclarationsFromDestructuring.ts — react Source File

ExtractScopeDeclarationsFromDestructuring.ts — react Source File

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

File typescript BabelCompiler Validation 11 imports 2 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  791ee72b_8a79_10a6_5a13_5297a1e50d89["ExtractScopeDeclarationsFromDestructuring.ts"]
  0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> 0423f759_97e0_9101_4634_ed555abc5ca9
  df6865e0_b573_e905_84d6_4eb6b419a888["HIRBuilder.ts"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> df6865e0_b573_e905_84d6_4eb6b419a888
  105d3afd_b3ee_3f37_2c92_eed7c3d1a5a0["clonePlaceToTemporary"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> 105d3afd_b3ee_3f37_2c92_eed7c3d1a5a0
  2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> 2f3caf55_cc64_415c_55dd_9771ba7dc210
  ebfb2dff_a701_0b9f_5a9e_8cd734914a21["eachInstructionLValueWithKind"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> ebfb2dff_a701_0b9f_5a9e_8cd734914a21
  f5637d03_fd91_50b8_9da7_b2a24c91bab7["eachPatternOperand"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> f5637d03_fd91_50b8_9da7_b2a24c91bab7
  f6e40907_93a0_cbc4_14eb_4d0ec248c01a["mapPatternOperands"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> f6e40907_93a0_cbc4_14eb_4d0ec248c01a
  21609915_b03a_fd75_b58a_4cb86ef9315b["visitors.ts"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> 21609915_b03a_fd75_b58a_4cb86ef9315b
  af3ace55_db6d_865e_92b9_81486f6af1e7["ReactiveFunctionTransform"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> af3ace55_db6d_865e_92b9_81486f6af1e7
  da7ad665_d709_433d_facd_dc3b2c4d34f5["Transformed"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> da7ad665_d709_433d_facd_dc3b2c4d34f5
  2435b5f8_41a6_0458_ba88_4479b965455f["visitReactiveFunction"]
  791ee72b_8a79_10a6_5a13_5297a1e50d89 --> 2435b5f8_41a6_0458_ba88_4479b965455f
  style 791ee72b_8a79_10a6_5a13_5297a1e50d89 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 {
  DeclarationId,
  Destructure,
  Environment,
  IdentifierId,
  InstructionKind,
  Place,
  ReactiveFunction,
  ReactiveInstruction,
  ReactiveScopeBlock,
  ReactiveStatement,
  promoteTemporary,
} from '../HIR';
import {clonePlaceToTemporary} from '../HIR/HIRBuilder';
import {
  eachInstructionLValueWithKind,
  eachPatternOperand,
  mapPatternOperands,
} from '../HIR/visitors';
import {
  ReactiveFunctionTransform,
  Transformed,
  visitReactiveFunction,
} from './visitors';

/*
 * Destructuring statements may sometimes define some variables which are declared by the scope,
 * and others that are only used locally within the scope, for example:
 *
 * ```
 * const {x, ...rest} = value;
 * return rest;
 * ```
 *
 * Here the scope structure turns into:
 *
 * ```
 * let c_0 = $[0] !== value;
 * let rest;
 * if (c_0) {
 *    // OOPS! we want to reassign `rest` here, but
 *    // `x` isn't declared anywhere!
 *    {x, ...rest} = value;
 *    $[0] = value;
 *    $[1] = rest;
 * } else {
 *    rest = $[1];
 * }
 * return rest;
 * ```
 *
 * Note that because `rest` is declared by the scope, we can't redeclare it in the
 * destructuring statement. But we have to declare `x`!
// ... (149 more lines)

Domain

Subdomains

Classes

Frequently Asked Questions

What does ExtractScopeDeclarationsFromDestructuring.ts do?
ExtractScopeDeclarationsFromDestructuring.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 ExtractScopeDeclarationsFromDestructuring.ts?
ExtractScopeDeclarationsFromDestructuring.ts defines 2 function(s): extractScopeDeclarationsFromDestructuring, transformDestructuring.
What does ExtractScopeDeclarationsFromDestructuring.ts depend on?
ExtractScopeDeclarationsFromDestructuring.ts imports 11 module(s): HIRBuilder.ts, ReactiveFunctionTransform, Transformed, clonePlaceToTemporary, eachInstructionLValueWithKind, eachPatternOperand, index.ts, mapPatternOperands, and 3 more.
Where is ExtractScopeDeclarationsFromDestructuring.ts in the architecture?
ExtractScopeDeclarationsFromDestructuring.ts is located at compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/ExtractScopeDeclarationsFromDestructuring.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