Home / Function/ writeNonOptionalDependency() — react Function Reference

writeNonOptionalDependency() — react Function Reference

Architecture documentation for the writeNonOptionalDependency() function in ScopeDependencyUtils.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d0800e5a_2d5f_1c1b_169c_b6c5cc895bee["writeNonOptionalDependency()"]
  a4fd6965_224d_0ddc_a6f9_b2f74cfd3994["ScopeDependencyUtils.ts"]
  d0800e5a_2d5f_1c1b_169c_b6c5cc895bee -->|defined in| a4fd6965_224d_0ddc_a6f9_b2f74cfd3994
  30907c46_684f_39cf_12ac_900130b902f4["buildDependencyInstructions()"]
  30907c46_684f_39cf_12ac_900130b902f4 -->|calls| d0800e5a_2d5f_1c1b_169c_b6c5cc895bee
  8e8a7c07_79b4_f2fb_53bd_2e3554679223["writeOptionalDependency()"]
  8e8a7c07_79b4_f2fb_53bd_2e3554679223 -->|calls| d0800e5a_2d5f_1c1b_169c_b6c5cc895bee
  4e7c3351_9e52_0196_d1f4_d8371b23d0cb["makeTemporaryIdentifier()"]
  d0800e5a_2d5f_1c1b_169c_b6c5cc895bee -->|calls| 4e7c3351_9e52_0196_d1f4_d8371b23d0cb
  d0270ab6_a621_bd55_a1b9_a5cad8b406b2["makeInstructionId()"]
  d0800e5a_2d5f_1c1b_169c_b6c5cc895bee -->|calls| d0270ab6_a621_bd55_a1b9_a5cad8b406b2
  53244187_914c_cc90_5880_7bfc1fc9c0bb["push()"]
  d0800e5a_2d5f_1c1b_169c_b6c5cc895bee -->|calls| 53244187_914c_cc90_5880_7bfc1fc9c0bb
  style d0800e5a_2d5f_1c1b_169c_b6c5cc895bee fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/ScopeDependencyUtils.ts lines 63–127

function writeNonOptionalDependency(
  dep: ReactiveScopeDependency,
  env: Environment,
  builder: HIRBuilder,
): Identifier {
  const loc = dep.identifier.loc;
  let curr: Identifier = makeTemporaryIdentifier(env.nextIdentifierId, loc);
  builder.push({
    lvalue: {
      identifier: curr,
      kind: 'Identifier',
      effect: Effect.Mutate,
      reactive: dep.reactive,
      loc,
    },
    value: {
      kind: 'LoadLocal',
      place: {
        identifier: dep.identifier,
        kind: 'Identifier',
        effect: Effect.Freeze,
        reactive: dep.reactive,
        loc,
      },
      loc,
    },
    id: makeInstructionId(1),
    loc: loc,
    effects: null,
  });

  /**
   * Iteratively build up dependency instructions by reading from the last written
   * instruction.
   */
  for (const path of dep.path) {
    const next = makeTemporaryIdentifier(env.nextIdentifierId, loc);
    builder.push({
      lvalue: {
        identifier: next,
        kind: 'Identifier',
        effect: Effect.Mutate,
        reactive: dep.reactive,
        loc,
      },
      value: {
        kind: 'PropertyLoad',
        object: {
          identifier: curr,
          kind: 'Identifier',
          effect: Effect.Freeze,
          reactive: dep.reactive,
          loc,
        },
        property: path.property,
        loc,
      },
      id: makeInstructionId(1),
      loc: loc,
      effects: null,
    });
    curr = next;
  }
  return curr;
}

Subdomains

Frequently Asked Questions

What does writeNonOptionalDependency() do?
writeNonOptionalDependency() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/ScopeDependencyUtils.ts.
Where is writeNonOptionalDependency() defined?
writeNonOptionalDependency() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/ScopeDependencyUtils.ts at line 63.
What does writeNonOptionalDependency() call?
writeNonOptionalDependency() calls 3 function(s): makeInstructionId, makeTemporaryIdentifier, push.
What calls writeNonOptionalDependency()?
writeNonOptionalDependency() is called by 2 function(s): buildDependencyInstructions, writeOptionalDependency.

Analyze Your Own Codebase

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

Try Supermodel Free