Home / Function/ visitInstruction() — react Function Reference

visitInstruction() — react Function Reference

Architecture documentation for the visitInstruction() function in PruneNonReactiveDependencies.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  98f294c7_67b7_0dd7_2e06_f6cd2c5c5526["visitInstruction()"]
  e2474ba6_08fb_6897_fff8_58e8e2c9fb71["Visitor"]
  98f294c7_67b7_0dd7_2e06_f6cd2c5c5526 -->|defined in| e2474ba6_08fb_6897_fff8_58e8e2c9fb71
  af4d3127_0abf_3e44_50a8_d7a9dd0b9b58["visitInstruction()"]
  98f294c7_67b7_0dd7_2e06_f6cd2c5c5526 -->|calls| af4d3127_0abf_3e44_50a8_d7a9dd0b9b58
  f5637d03_fd91_50b8_9da7_b2a24c91bab7["eachPatternOperand()"]
  98f294c7_67b7_0dd7_2e06_f6cd2c5c5526 -->|calls| f5637d03_fd91_50b8_9da7_b2a24c91bab7
  940018a6_e890_d3b5_6044_cb8053953421["traverseInstruction()"]
  98f294c7_67b7_0dd7_2e06_f6cd2c5c5526 -->|calls| 940018a6_e890_d3b5_6044_cb8053953421
  style 98f294c7_67b7_0dd7_2e06_f6cd2c5c5526 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonReactiveDependencies.ts lines 33–91

  override visitInstruction(
    instruction: ReactiveInstruction,
    state: ReactiveIdentifiers,
  ): void {
    this.traverseInstruction(instruction, state);

    const {lvalue, value} = instruction;
    switch (value.kind) {
      case 'LoadLocal': {
        if (lvalue !== null && state.has(value.place.identifier.id)) {
          state.add(lvalue.identifier.id);
        }
        break;
      }
      case 'StoreLocal': {
        if (state.has(value.value.identifier.id)) {
          state.add(value.lvalue.place.identifier.id);
          if (lvalue !== null) {
            state.add(lvalue.identifier.id);
          }
        }
        break;
      }
      case 'Destructure': {
        if (state.has(value.value.identifier.id)) {
          for (const lvalue of eachPatternOperand(value.lvalue.pattern)) {
            if (isStableType(lvalue.identifier)) {
              continue;
            }
            state.add(lvalue.identifier.id);
          }
          if (lvalue !== null) {
            state.add(lvalue.identifier.id);
          }
        }
        break;
      }
      case 'PropertyLoad': {
        if (
          lvalue !== null &&
          state.has(value.object.identifier.id) &&
          !isStableType(lvalue.identifier)
        ) {
          state.add(lvalue.identifier.id);
        }
        break;
      }
      case 'ComputedLoad': {
        if (
          lvalue !== null &&
          (state.has(value.object.identifier.id) ||
            state.has(value.property.identifier.id))
        ) {
          state.add(lvalue.identifier.id);
        }
        break;
      }
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does visitInstruction() do?
visitInstruction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonReactiveDependencies.ts.
Where is visitInstruction() defined?
visitInstruction() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonReactiveDependencies.ts at line 33.
What does visitInstruction() call?
visitInstruction() calls 3 function(s): eachPatternOperand, traverseInstruction, visitInstruction.

Analyze Your Own Codebase

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

Try Supermodel Free