Home / Function/ print() — react Function Reference

print() — react Function Reference

Architecture documentation for the print() function in InstructionReordering.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  7b9ee6ee_c43a_8594_2d2b_4347e2e623a4["print()"]
  dc3f5251_a95c_3c77_5550_3882c13a37c9["InstructionReordering.ts"]
  7b9ee6ee_c43a_8594_2d2b_4347e2e623a4 -->|defined in| dc3f5251_a95c_3c77_5550_3882c13a37c9
  c4483c48_7e67_41a0_1a7a_c6ca92a55123["reorderBlock()"]
  c4483c48_7e67_41a0_1a7a_c6ca92a55123 -->|calls| 7b9ee6ee_c43a_8594_2d2b_4347e2e623a4
  c7c1eb69_eed3_63a6_a393_058189e67642["getDepth()"]
  7b9ee6ee_c43a_8594_2d2b_4347e2e623a4 -->|calls| c7c1eb69_eed3_63a6_a393_058189e67642
  843b9a2f_f7fa_8b25_52a1_e24f3185eefc["printNode()"]
  7b9ee6ee_c43a_8594_2d2b_4347e2e623a4 -->|calls| 843b9a2f_f7fa_8b25_52a1_e24f3185eefc
  style 7b9ee6ee_c43a_8594_2d2b_4347e2e623a4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts lines 389–421

function print(
  env: Environment,
  locals: Nodes,
  shared: Nodes,
  seen: Set<IdentifierId>,
  id: IdentifierId,
  depth: number = 0,
): void {
  if (seen.has(id)) {
    DEBUG && console.log(`${'|   '.repeat(depth)}$${id} <skipped>`);
    return;
  }
  seen.add(id);
  const node = locals.get(id) ?? shared.get(id);
  if (node == null) {
    return;
  }
  const deps = [...node.dependencies];
  deps.sort((a, b) => {
    const aDepth = getDepth(env, locals, a);
    const bDepth = getDepth(env, locals, b);
    return bDepth - aDepth;
  });
  for (const dep of deps) {
    print(env, locals, shared, seen, dep, depth + 1);
  }
  DEBUG &&
    console.log(
      `${'|   '.repeat(depth)}$${id} ${printNode(node)} deps=[${deps
        .map(x => `$${x}`)
        .join(', ')}] depth=${node.depth}`,
    );
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does print() do?
print() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts.
Where is print() defined?
print() is defined in compiler/packages/babel-plugin-react-compiler/src/Optimization/InstructionReordering.ts at line 389.
What does print() call?
print() calls 2 function(s): getDepth, printNode.
What calls print()?
print() is called by 1 function(s): reorderBlock.

Analyze Your Own Codebase

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

Try Supermodel Free