RewriteInstructionKindsBasedOnReassignment.ts — react Source File
Architecture documentation for RewriteInstructionKindsBasedOnReassignment.ts, a typescript file in the react codebase. 13 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 11a22739_6713_26cd_7efc_ba4dab5043a4["RewriteInstructionKindsBasedOnReassignment.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> e96f281e_f381_272d_2359_3e6a091c9a1d e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> e51fd0d2_bb38_cc97_7763_efe37f300a47 18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> 18a78965_f593_105b_e5e8_07001321c2ec bf1aef24_2e0f_0adb_12d8_9e5ba8245644["DeclarationId"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> bf1aef24_2e0f_0adb_12d8_9e5ba8245644 9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> 9241c5c1_a9a7_17bc_e41c_e967225008dd 03aa18e2_bd2c_e9cb_5973_bae3ec02373c["InstructionKind"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> 03aa18e2_bd2c_e9cb_5973_bae3ec02373c 2600c242_e197_40ed_88ed_e8f74c4793bd["LValue"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> 2600c242_e197_40ed_88ed_e8f74c4793bd 917c2014_dff4_f0d5_bb79_1c9f6d78676a["LValuePattern"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> 917c2014_dff4_f0d5_bb79_1c9f6d78676a c7aaa235_c19e_3530_31c2_911f38eed3e0["Place"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> c7aaa235_c19e_3530_31c2_911f38eed3e0 6976a9ee_9d8e_4f16_3016_495f39aff2fd["PrintHIR.ts"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> 6976a9ee_9d8e_4f16_3016_495f39aff2fd bf7f1cf7_fc0e_6bac_827c_8d36d98126da["printPlace"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> bf7f1cf7_fc0e_6bac_827c_8d36d98126da 2f3caf55_cc64_415c_55dd_9771ba7dc210["visitors.ts"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> 2f3caf55_cc64_415c_55dd_9771ba7dc210 f5637d03_fd91_50b8_9da7_b2a24c91bab7["eachPatternOperand"] 11a22739_6713_26cd_7efc_ba4dab5043a4 --> f5637d03_fd91_50b8_9da7_b2a24c91bab7 style 11a22739_6713_26cd_7efc_ba4dab5043a4 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 {
DeclarationId,
GeneratedSource,
HIRFunction,
InstructionKind,
LValue,
LValuePattern,
Place,
} from '../HIR/HIR';
import {printPlace} from '../HIR/PrintHIR';
import {eachPatternOperand} from '../HIR/visitors';
/**
* This pass rewrites the InstructionKind of instructions which declare/assign variables,
* converting the first declaration to a Const/Let depending on whether it is subsequently
* reassigned, and ensuring that subsequent reassignments are marked as a Reassign. Note
* that declarations which were const in the original program cannot become `let`, but the
* inverse is not true: a `let` which was reassigned in the source may be converted to a
* `const` if the reassignment is not used and was removed by dead code elimination.
*
* NOTE: this is a subset of the operations previously performed by the LeaveSSA pass.
*/
export function rewriteInstructionKindsBasedOnReassignment(
fn: HIRFunction,
): void {
const declarations = new Map<DeclarationId, LValue | LValuePattern>();
for (const param of fn.params) {
let place: Place = param.kind === 'Identifier' ? param : param.place;
if (place.identifier.name !== null) {
declarations.set(place.identifier.declarationId, {
kind: InstructionKind.Let,
place,
});
}
}
for (const place of fn.context) {
if (place.identifier.name !== null) {
declarations.set(place.identifier.declarationId, {
kind: InstructionKind.Let,
place,
});
}
}
for (const [, block] of fn.body.blocks) {
for (const instr of block.instructions) {
const {value} = instr;
switch (value.kind) {
case 'DeclareLocal': {
const lvalue = value.lvalue;
CompilerError.invariant(
!declarations.has(lvalue.place.identifier.declarationId),
{
// ... (109 more lines)
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does RewriteInstructionKindsBasedOnReassignment.ts do?
RewriteInstructionKindsBasedOnReassignment.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 RewriteInstructionKindsBasedOnReassignment.ts?
RewriteInstructionKindsBasedOnReassignment.ts defines 1 function(s): rewriteInstructionKindsBasedOnReassignment.
What does RewriteInstructionKindsBasedOnReassignment.ts depend on?
RewriteInstructionKindsBasedOnReassignment.ts imports 13 module(s): CompilerError, CompilerError.ts, DeclarationId, HIR.ts, HIRFunction, InstructionKind, LValue, LValuePattern, and 5 more.
Where is RewriteInstructionKindsBasedOnReassignment.ts in the architecture?
RewriteInstructionKindsBasedOnReassignment.ts is located at compiler/packages/babel-plugin-react-compiler/src/SSA/RewriteInstructionKindsBasedOnReassignment.ts (domain: MIRInfrastructure, subdomain: HIR, directory: compiler/packages/babel-plugin-react-compiler/src/SSA).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free