HIR.ts — react Source File
Architecture documentation for HIR.ts, a typescript file in the react codebase. 23 imports, 47 dependents.
Entity Profile
Dependency Diagram
graph LR 18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"] e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"] 18a78965_f593_105b_e5e8_07001321c2ec --> e96f281e_f381_272d_2359_3e6a091c9a1d 0fda7f86_b7a3_c1f2_f0d9_8d13eed4f042["CompilerDiagnostic"] 18a78965_f593_105b_e5e8_07001321c2ec --> 0fda7f86_b7a3_c1f2_f0d9_8d13eed4f042 e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"] 18a78965_f593_105b_e5e8_07001321c2ec --> e51fd0d2_bb38_cc97_7763_efe37f300a47 a2b91621_58d3_1d04_4663_00cd808f1034["ErrorCategory"] 18a78965_f593_105b_e5e8_07001321c2ec --> a2b91621_58d3_1d04_4663_00cd808f1034 eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"] 18a78965_f593_105b_e5e8_07001321c2ec --> eb9d33f9_42c1_205c_93e6_8e1365a31839 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive"] 18a78965_f593_105b_e5e8_07001321c2ec --> d7fde76c_4fd9_feb3_299b_798689f05bc6 1b971013_8a90_0d8d_1fcc_f31581cd66aa["Environment.ts"] 18a78965_f593_105b_e5e8_07001321c2ec --> 1b971013_8a90_0d8d_1fcc_f31581cd66aa cba0c8a2_0db5_48e2_0d19_b2c6a46799e8["Environment"] 18a78965_f593_105b_e5e8_07001321c2ec --> cba0c8a2_0db5_48e2_0d19_b2c6a46799e8 3d4f48f2_0491_af90_7077_5573865bf9da["ReactFunctionType"] 18a78965_f593_105b_e5e8_07001321c2ec --> 3d4f48f2_0491_af90_7077_5573865bf9da 58f81300_7c82_5086_3e10_e46b5f3ab04d["ObjectShape.ts"] 18a78965_f593_105b_e5e8_07001321c2ec --> 58f81300_7c82_5086_3e10_e46b5f3ab04d f1874e3c_f8f2_5f68_d3a9_0c56c0dad5ec["Types.ts"] 18a78965_f593_105b_e5e8_07001321c2ec --> f1874e3c_f8f2_5f68_d3a9_0c56c0dad5ec 6700f63d_bcbd_1a9f_8cd9_05e34a927b23["Type"] 18a78965_f593_105b_e5e8_07001321c2ec --> 6700f63d_bcbd_1a9f_8cd9_05e34a927b23 c50e6c61_a100_0e6f_983b_951164ba4856["makeType"] 18a78965_f593_105b_e5e8_07001321c2ec --> c50e6c61_a100_0e6f_983b_951164ba4856 2f00e901_2271_5b46_4d72_3fa77ff15e31["AliasingEffects.ts"] 18a78965_f593_105b_e5e8_07001321c2ec --> 2f00e901_2271_5b46_4d72_3fa77ff15e31 style 18a78965_f593_105b_e5e8_07001321c2ec 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 {BindingKind} from '@babel/traverse';
import * as t from '@babel/types';
import {
CompilerDiagnostic,
CompilerError,
ErrorCategory,
} from '../CompilerError';
import {assertExhaustive} from '../Utils/utils';
import {Environment, ReactFunctionType} from './Environment';
import type {HookKind} from './ObjectShape';
import {Type, makeType} from './Types';
import {z} from 'zod/v4';
import type {AliasingEffect} from '../Inference/AliasingEffects';
import {isReservedWord} from '../Utils/Keyword';
import {Err, Ok, Result} from '../Utils/Result';
/*
* *******************************************************************************************
* *******************************************************************************************
* ************************************* Core Data Model *************************************
* *******************************************************************************************
* *******************************************************************************************
*/
// AST -> (lowering) -> HIR -> (analysis) -> Reactive Scopes -> (codegen) -> AST
/*
* A location in a source file, intended to be used for providing diagnostic information and
* transforming code while preserving source information (ie to emit source maps).
*
* `GeneratedSource` indicates that there is no single source location from which the code derives.
*/
export const GeneratedSource = Symbol();
export type SourceLocation = t.SourceLocation | typeof GeneratedSource;
/*
* A React function defines a computation that takes some set of reactive inputs
* (props, hook arguments) and return a result (JSX, hook return value). Unlike
* HIR, the data model is tree-shaped:
*
* ReactFunction
* ReactiveBlock
* ReactiveBlockScope*
* Place* (dependencies)
* (ReactiveInstruction | ReactiveTerminal)*
*
* Where ReactiveTerminal may recursively contain zero or more ReactiveBlocks.
*
* Each ReactiveBlockScope describes a set of dependencies as well as the instructions (and terminals)
* within that scope.
*/
export type ReactiveFunction = {
loc: SourceLocation;
// ... (1940 more lines)
Domain
Subdomains
Functions
- _staticInvariantInstructionValueHasLocation()
- _staticInvariantReactiveTerminalHasInstructionId()
- _staticInvariantReactiveTerminalHasLocation()
- _staticInvariantTerminalHasFallthrough()
- _staticInvariantTerminalHasInstructionId()
- _staticInvariantTerminalHasLocation()
- areEqualPaths()
- convertHoistedLValueKind()
- evaluatesToStableTypeOrContainer()
- forkTemporaryIdentifier()
- getHookKind()
- getHookKindForType()
- getPlaceScope()
- isArrayType()
- isDispatcherType()
- isEffectEventFunctionType()
- isExpressionBlockKind()
- isFireFunctionType()
- isJsxType()
- isMapType()
- isMutableEffect()
- isObjectMethodType()
- isObjectType()
- isPlainObjectType()
- isPrimitiveType()
- isPromotedJsxTemporary()
- isPromotedTemporary()
- isPropsType()
- isRefOrRefLikeMutableType()
- isRefOrRefValue()
- isRefValueType()
- isScopeActive()
- isSetActionStateType()
- isSetOptimisticType()
- isSetStateType()
- isSetType()
- isStableType()
- isStableTypeContainer()
- isStartTransitionType()
- isStatementBlockKind()
- isSubPath()
- isSubPathIgnoringOptionals()
- isUseActionStateType()
- isUseContextHookType()
- isUseEffectEventType()
- isUseEffectHookType()
- isUseInsertionEffectHookType()
- isUseLayoutEffectHookType()
- isUseOperator()
- isUseOptimisticType()
- isUseReducerType()
- isUseRefType()
- isUseStateType()
- makeBlockId()
- makeDeclarationId()
- makeIdentifierId()
- makeIdentifierName()
- makeInstructionId()
- makePropertyLiteral()
- makeScopeId()
- makeTemporaryIdentifier()
- promoteTemporary()
- promoteTemporaryJsxTag()
- validateIdentifierName()
Types
- AbstractValue
- ArrayExpression
- ArrayPattern
- BasicBlock
- BlockId
- BlockKind
- BranchTerminal
- BuiltinTag
- CallExpression
- Case
- DeclarationId
- DependencyPath
- DependencyPathEntry
- Destructure
- DoWhileTerminal
- Effect
- FinishMemoize
- ForInTerminal
- ForOfTerminal
- ForTerminal
- FunctionExpression
- GotoTerminal
- GotoVariant
- HIR
- HIRFunction
- Hole
- Identifier
- IdentifierId
- IdentifierName
- IfTerminal
- Instruction
- InstructionId
- InstructionKind
- InstructionValue
- JSXText
- JsxAttribute
- JsxExpression
- LValue
- LValuePattern
- LabelTerminal
- LoadContext
- LoadGlobal
- LoadLocal
- LogicalTerminal
- LoweredFunction
- ManualMemoDependency
- MaybeThrowTerminal
- MethodCall
- MutableRange
- NewExpression
- NonLocalBinding
- NonLocalImportSpecifier
- ObjectMethod
- ObjectPattern
- ObjectProperty
- ObjectPropertyKey
- OptionalTerminal
- Pattern
- Phi
- Place
- Primitive
- PromotedIdentifier
- PropertyLiteral
- PropertyLoad
- PrunedReactiveScopeBlock
- PrunedScopeTerminal
- ReactiveBlock
- ReactiveBreakTerminal
- ReactiveContinueTerminal
- ReactiveDoWhileTerminal
- ReactiveForInTerminal
- ReactiveForOfTerminal
- ReactiveForTerminal
- ReactiveFunction
- ReactiveIfTerminal
- ReactiveInstruction
- ReactiveInstructionStatement
- ReactiveLabelTerminal
- ReactiveLogicalValue
- ReactiveOptionalCallValue
- ReactiveReturnTerminal
- ReactiveScope
- ReactiveScopeBlock
- ReactiveScopeDeclaration
- ReactiveScopeDependencies
- ReactiveScopeDependency
- ReactiveScopeTerminal
- ReactiveSequenceValue
- ReactiveStatement
- ReactiveSwitchTerminal
- ReactiveTerminal
- ReactiveTerminalStatement
- ReactiveTerminalTargetKind
- ReactiveTernaryValue
- ReactiveThrowTerminal
- ReactiveTryTerminal
- ReactiveValue
- ReactiveWhileTerminal
- ReturnTerminal
- ReturnVariant
- ScopeId
- SequenceTerminal
- SourceLocation
- SpreadPattern
- StartMemoize
- StoreGlobal
- StoreLocal
- SwitchTerminal
- TBasicBlock
- TInstruction
- Terminal
- TerminalWithFallthrough
- TernaryTerminal
- ThrowTerminal
- TryTerminal
- UnreachableTerminal
- UnsupportedTerminal
- ValidIdentifierName
- ValidatedIdentifier
- ValueKind
- ValueReason
- VariableBinding
- WhileTerminal
Dependencies
Imported By
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AlignReactiveScopesToBlockScopesHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/AssertConsistentIdentifiers.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AssertScopeInstructionsWithinScope.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/AssertTerminalBlocksExist.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/AssertValidBlockNesting.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/AssertValidMutableRanges.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/BuildReactiveScopeTerminalsHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CollectReactiveIdentifiers.ts
- compiler/packages/babel-plugin-react-compiler/src/Utils/DisjointSet.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.ts
- compiler/packages/babel-plugin-react-compiler/src/SSA/EliminateRedundantPhi.ts
- compiler/packages/babel-plugin-react-compiler/src/SSA/EnterSSA.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/FindContextIdentifiers.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts
- compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingRanges.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/InferReactiveScopeVariables.ts
- compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/MergeConsecutiveBlocks.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts
- compiler/packages/babel-plugin-react-compiler/src/Optimization/OutlineJsx.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PromoteUsedTemporaries.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneAllReactiveScopes.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneTemporaryLValues.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneUnusedLabels.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/PruneUnusedLabelsHIR.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneUnusedScopes.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/RenameVariables.ts
- compiler/packages/babel-plugin-react-compiler/src/SSA/RewriteInstructionKindsBasedOnReassignment.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/ScopeDependencyUtils.ts
- compiler/packages/babel-plugin-react-compiler/src/Utils/TestUtils.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/TypeSchema.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/Types.ts
- compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateHooksUsage.ts
- compiler/packages/babel-plugin-react-compiler/src/HIR/visitors.ts
- compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/visitors.ts
Source
Frequently Asked Questions
What does HIR.ts do?
HIR.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 HIR.ts?
HIR.ts defines 64 function(s): _staticInvariantInstructionValueHasLocation, _staticInvariantReactiveTerminalHasInstructionId, _staticInvariantReactiveTerminalHasLocation, _staticInvariantTerminalHasFallthrough, _staticInvariantTerminalHasInstructionId, _staticInvariantTerminalHasLocation, areEqualPaths, convertHoistedLValueKind, evaluatesToStableTypeOrContainer, forkTemporaryIdentifier, and 54 more.
What does HIR.ts depend on?
HIR.ts imports 23 module(s): AliasingEffects.ts, CompilerDiagnostic, CompilerError, CompilerError.ts, Environment, Environment.ts, Err, ErrorCategory, and 15 more.
What files import HIR.ts?
HIR.ts is imported by 47 file(s): AlignReactiveScopesToBlockScopesHIR.ts, AssertConsistentIdentifiers.ts, AssertScopeInstructionsWithinScope.ts, AssertTerminalBlocksExist.ts, AssertValidBlockNesting.ts, AssertValidMutableRanges.ts, BuildHIR.ts, BuildReactiveFunction.ts, and 39 more.
Where is HIR.ts in the architecture?
HIR.ts is located at compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts (domain: MIRInfrastructure, subdomain: HIR, directory: compiler/packages/babel-plugin-react-compiler/src/HIR).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free