Home / File/ LowerContextAccess.ts — react Source File

LowerContextAccess.ts — react Source File

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

File typescript BabelCompiler Validation 5 imports 1 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  ed770299_f9db_61d4_407c_b8ead52e24ec["LowerContextAccess.ts"]
  0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"]
  ed770299_f9db_61d4_407c_b8ead52e24ec --> 0423f759_97e0_9101_4634_ed555abc5ca9
  df6865e0_b573_e905_84d6_4eb6b419a888["HIRBuilder.ts"]
  ed770299_f9db_61d4_407c_b8ead52e24ec --> df6865e0_b573_e905_84d6_4eb6b419a888
  49446ae1_b830_9411_8258_1139d21b314b["createTemporaryPlace"]
  ed770299_f9db_61d4_407c_b8ead52e24ec --> 49446ae1_b830_9411_8258_1139d21b314b
  d2425665_ca9d_6abf_459e_d86a6540ef14["index.ts"]
  ed770299_f9db_61d4_407c_b8ead52e24ec --> d2425665_ca9d_6abf_459e_d86a6540ef14
  85b34911_47bc_4b1e_4b1b_b4b57280789e["index.ts"]
  ed770299_f9db_61d4_407c_b8ead52e24ec --> 85b34911_47bc_4b1e_4b1b_b4b57280789e
  e3cfc07a_10c8_5dcd_e270_e8e14c29309b["Pipeline.ts"]
  e3cfc07a_10c8_5dcd_e270_e8e14c29309b --> ed770299_f9db_61d4_407c_b8ead52e24ec
  style ed770299_f9db_61d4_407c_b8ead52e24ec 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 {
  ArrayExpression,
  BasicBlock,
  CallExpression,
  Destructure,
  Environment,
  ExternalFunction,
  GeneratedSource,
  HIRFunction,
  IdentifierId,
  Instruction,
  LoadGlobal,
  LoadLocal,
  NonLocalImportSpecifier,
  Place,
  PropertyLoad,
  isUseContextHookType,
  makeBlockId,
  makeInstructionId,
  makePropertyLiteral,
  markInstructionIds,
  promoteTemporary,
  reversePostorderBlocks,
} from '../HIR';
import {createTemporaryPlace} from '../HIR/HIRBuilder';
import {enterSSA} from '../SSA';
import {inferTypes} from '../TypeInference';

export function lowerContextAccess(
  fn: HIRFunction,
  loweredContextCalleeConfig: ExternalFunction,
): void {
  const contextAccess: Map<IdentifierId, CallExpression> = new Map();
  const contextKeys: Map<IdentifierId, Array<string>> = new Map();

  // collect context access and keys
  for (const [, block] of fn.body.blocks) {
    for (const instr of block.instructions) {
      const {value, lvalue} = instr;

      if (
        value.kind === 'CallExpression' &&
        isUseContextHookType(value.callee.identifier)
      ) {
        contextAccess.set(lvalue.identifier.id, value);
        continue;
      }

      if (value.kind !== 'Destructure') {
        continue;
      }

      const destructureId = value.value.identifier.id;
// ... (249 more lines)

Domain

Subdomains

Frequently Asked Questions

What does LowerContextAccess.ts do?
LowerContextAccess.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 LowerContextAccess.ts?
LowerContextAccess.ts defines 6 function(s): emitArrayInstr, emitLoadLoweredContextCallee, emitPropertyLoad, emitSelectorFn, getContextKeys, lowerContextAccess.
What does LowerContextAccess.ts depend on?
LowerContextAccess.ts imports 5 module(s): HIRBuilder.ts, createTemporaryPlace, index.ts, index.ts, index.ts.
What files import LowerContextAccess.ts?
LowerContextAccess.ts is imported by 1 file(s): Pipeline.ts.
Where is LowerContextAccess.ts in the architecture?
LowerContextAccess.ts is located at compiler/packages/babel-plugin-react-compiler/src/Optimization/LowerContextAccess.ts (domain: BabelCompiler, subdomain: Validation, directory: compiler/packages/babel-plugin-react-compiler/src/Optimization).

Analyze Your Own Codebase

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

Try Supermodel Free