Home / File/ PrintReactiveFunction.ts — react Source File

PrintReactiveFunction.ts — react Source File

Architecture documentation for PrintReactiveFunction.ts, a typescript file in the react codebase. 19 imports, 3 dependents.

File typescript BabelCompiler Validation 19 imports 3 dependents 14 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  d77f9ffb_2d12_7d1f_126f_8c05214f0059["PrintReactiveFunction.ts"]
  e96f281e_f381_272d_2359_3e6a091c9a1d["CompilerError.ts"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> e96f281e_f381_272d_2359_3e6a091c9a1d
  e51fd0d2_bb38_cc97_7763_efe37f300a47["CompilerError"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> e51fd0d2_bb38_cc97_7763_efe37f300a47
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 18a78965_f593_105b_e5e8_07001321c2ec
  02f69dfe_af02_6deb_8891_1b0229142fd1["PrunedReactiveScopeBlock"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 02f69dfe_af02_6deb_8891_1b0229142fd1
  c0555545_1ea3_9d37_62ad_521eafe2daa8["ReactiveFunction"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> c0555545_1ea3_9d37_62ad_521eafe2daa8
  ca9a6820_460e_0b15_8169_3aa4c6503770["ReactiveScope"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> ca9a6820_460e_0b15_8169_3aa4c6503770
  0fba6722_c385_0076_d75b_47ee3ff87ee3["ReactiveScopeBlock"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 0fba6722_c385_0076_d75b_47ee3ff87ee3
  67538878_fe95_51b1_23f8_f71e2575832c["ReactiveScopeDependency"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 67538878_fe95_51b1_23f8_f71e2575832c
  d2571adf_c2aa_1e5e_5c56_f26810a3829e["ReactiveStatement"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> d2571adf_c2aa_1e5e_5c56_f26810a3829e
  4b88d9db_fbef_bf80_04be_63232e2e4dc0["ReactiveTerminal"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 4b88d9db_fbef_bf80_04be_63232e2e4dc0
  03931fe0_84fd_a4e9_b75a_03f9d092be95["ReactiveValue"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 03931fe0_84fd_a4e9_b75a_03f9d092be95
  6976a9ee_9d8e_4f16_3016_495f39aff2fd["PrintHIR.ts"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 6976a9ee_9d8e_4f16_3016_495f39aff2fd
  75108b98_1828_cb14_243d_e48c6613b748["printFunction"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> 75108b98_1828_cb14_243d_e48c6613b748
  e7a01d7c_c128_be66_a07d_007952a380da["printIdentifier"]
  d77f9ffb_2d12_7d1f_126f_8c05214f0059 --> e7a01d7c_c128_be66_a07d_007952a380da
  style d77f9ffb_2d12_7d1f_126f_8c05214f0059 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 {
  GeneratedSource,
  PrunedReactiveScopeBlock,
  ReactiveFunction,
  ReactiveScope,
  ReactiveScopeBlock,
  ReactiveScopeDependency,
  ReactiveStatement,
  ReactiveTerminal,
  ReactiveValue,
} from '../HIR/HIR';
import {
  printFunction,
  printIdentifier,
  printInstructionValue,
  printPlace,
  printType,
} from '../HIR/PrintHIR';
import {assertExhaustive} from '../Utils/utils';

export function printReactiveFunctionWithOutlined(
  fn: ReactiveFunction,
): string {
  const writer = new Writer();
  writeReactiveFunction(fn, writer);
  for (const outlined of fn.env.getOutlinedFunctions()) {
    writer.writeLine('\nfunction ' + printFunction(outlined.fn));
  }
  return writer.complete();
}

export function printReactiveFunction(fn: ReactiveFunction): string {
  const writer = new Writer();
  writeReactiveFunction(fn, writer);
  return writer.complete();
}

function writeReactiveFunction(fn: ReactiveFunction, writer: Writer): void {
  writer.writeLine(`function ${fn.id !== null ? fn.id : '<unknown>'}(`);
  writer.indented(() => {
    for (const param of fn.params) {
      if (param.kind === 'Identifier') {
        writer.writeLine(`${printPlace(param)},`);
      } else {
        writer.writeLine(`...${printPlace(param.place)},`);
      }
    }
  });
  writer.writeLine(') {');
  writeReactiveInstructions(writer, fn.body);
  writer.writeLine('}');
}
// ... (398 more lines)

Domain

Subdomains

Classes

Frequently Asked Questions

What does PrintReactiveFunction.ts do?
PrintReactiveFunction.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 PrintReactiveFunction.ts?
PrintReactiveFunction.ts defines 14 function(s): printDependency, printReactiveFunction, printReactiveFunctionWithOutlined, printReactiveInstructions, printReactiveScopeSummary, printReactiveTerminal, printReactiveValue, writePrunedScope, writeReactiveBlock, writeReactiveFunction, and 4 more.
What does PrintReactiveFunction.ts depend on?
PrintReactiveFunction.ts imports 19 module(s): CompilerError, CompilerError.ts, HIR.ts, PrintHIR.ts, PrunedReactiveScopeBlock, ReactiveFunction, ReactiveScope, ReactiveScopeBlock, and 11 more.
What files import PrintReactiveFunction.ts?
PrintReactiveFunction.ts is imported by 3 file(s): CollectHoistablePropertyLoads.ts, MergeReactiveScopesThatInvalidateTogether.ts, PrintHIR.ts.
Where is PrintReactiveFunction.ts in the architecture?
PrintReactiveFunction.ts is located at compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PrintReactiveFunction.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