Home / File/ BuildReactiveFunction.ts — react Source File

BuildReactiveFunction.ts — react Source File

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

File typescript BabelCompiler Validation 18 imports 1 dependents 1 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  3e304366_7140_93cb_47c8_0d400140265a["BuildReactiveFunction.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  3e304366_7140_93cb_47c8_0d400140265a --> e96f281e_f381_272d_2359_3e6a091c9a1d
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  3e304366_7140_93cb_47c8_0d400140265a --> e51fd0d2_bb38_cc97_7763_efe37f300a47
  0423f759_97e0_9101_4634_ed555abc5ca9["index.ts"]
  3e304366_7140_93cb_47c8_0d400140265a --> 0423f759_97e0_9101_4634_ed555abc5ca9
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  3e304366_7140_93cb_47c8_0d400140265a --> 18a78965_f593_105b_e5e8_07001321c2ec
  9241c5c1_a9a7_17bc_e41c_e967225008dd["HIRFunction"]
  3e304366_7140_93cb_47c8_0d400140265a --> 9241c5c1_a9a7_17bc_e41c_e967225008dd
  6712b3e7_a667_6484_817f_685715d401c6["ReactiveBreakTerminal"]
  3e304366_7140_93cb_47c8_0d400140265a --> 6712b3e7_a667_6484_817f_685715d401c6
  3e664232_0b48_a308_3902_10ea7ec05c67["ReactiveContinueTerminal"]
  3e304366_7140_93cb_47c8_0d400140265a --> 3e664232_0b48_a308_3902_10ea7ec05c67
  c0555545_1ea3_9d37_62ad_521eafe2daa8["ReactiveFunction"]
  3e304366_7140_93cb_47c8_0d400140265a --> c0555545_1ea3_9d37_62ad_521eafe2daa8
  60e40c84_1324_6a2b_a7cf_f69d86f17579["ReactiveInstruction"]
  3e304366_7140_93cb_47c8_0d400140265a --> 60e40c84_1324_6a2b_a7cf_f69d86f17579
  7ac6e951_b8d0_6963_1214_f87bf49d13a0["ReactiveLogicalValue"]
  3e304366_7140_93cb_47c8_0d400140265a --> 7ac6e951_b8d0_6963_1214_f87bf49d13a0
  a49e9d8f_1967_9bd3_257f_1fa390363e44["ReactiveSequenceValue"]
  3e304366_7140_93cb_47c8_0d400140265a --> a49e9d8f_1967_9bd3_257f_1fa390363e44
  97848b70_4205_af8b_cc43_f635e9b08163["ReactiveTerminalStatement"]
  3e304366_7140_93cb_47c8_0d400140265a --> 97848b70_4205_af8b_cc43_f635e9b08163
  38182ebb_05f0_aa1f_0880_dbb0e59e7c95["ReactiveTerminalTargetKind"]
  3e304366_7140_93cb_47c8_0d400140265a --> 38182ebb_05f0_aa1f_0880_dbb0e59e7c95
  11a474a6_5cde_80a6_7e12_8021b658d571["ReactiveTernaryValue"]
  3e304366_7140_93cb_47c8_0d400140265a --> 11a474a6_5cde_80a6_7e12_8021b658d571
  style 3e304366_7140_93cb_47c8_0d400140265a 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 {
  BasicBlock,
  BlockId,
  GeneratedSource,
  GotoVariant,
  HIR,
  InstructionId,
  Place,
  ReactiveBlock,
  SourceLocation,
} from '../HIR';
import {
  HIRFunction,
  ReactiveBreakTerminal,
  ReactiveContinueTerminal,
  ReactiveFunction,
  ReactiveInstruction,
  ReactiveLogicalValue,
  ReactiveSequenceValue,
  ReactiveTerminalStatement,
  ReactiveTerminalTargetKind,
  ReactiveTernaryValue,
  ReactiveValue,
  Terminal,
} from '../HIR/HIR';
import {assertExhaustive} from '../Utils/utils';

/*
 * Converts from HIR (lower-level CFG) to ReactiveFunction, a tree representation
 * that is closer to an AST. This pass restores the original control flow constructs,
 * including break/continue to labeled statements. Note that this pass naively emits
 * labels for *all* terminals: see PruneUnusedLabels which removes unnecessary labels.
 */
export function buildReactiveFunction(fn: HIRFunction): ReactiveFunction {
  const cx = new Context(fn.body);
  const driver = new Driver(cx);
  const body = driver.traverseBlock(cx.block(fn.body.entry));
  return {
    loc: fn.loc,
    id: fn.id,
    nameHint: fn.nameHint,
    params: fn.params,
    generator: fn.generator,
    async: fn.async,
    body,
    env: fn.env,
    directives: fn.directives,
  };
}

class Driver {
  cx: Context;
// ... (1428 more lines)

Domain

Subdomains

Classes

Frequently Asked Questions

What does BuildReactiveFunction.ts do?
BuildReactiveFunction.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 BuildReactiveFunction.ts?
BuildReactiveFunction.ts defines 1 function(s): buildReactiveFunction.
What does BuildReactiveFunction.ts depend on?
BuildReactiveFunction.ts imports 18 module(s): CompilerError, CompilerError.ts, HIR.ts, HIRFunction, ReactiveBreakTerminal, ReactiveContinueTerminal, ReactiveFunction, ReactiveInstruction, and 10 more.
What files import BuildReactiveFunction.ts?
BuildReactiveFunction.ts is imported by 1 file(s): CodegenReactiveFunction.ts.
Where is BuildReactiveFunction.ts in the architecture?
BuildReactiveFunction.ts is located at compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.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