Home / Class/ CheckInstructionsAgainstScopesVisitor Class — react Architecture

CheckInstructionsAgainstScopesVisitor Class — react Architecture

Architecture documentation for the CheckInstructionsAgainstScopesVisitor class in AssertScopeInstructionsWithinScope.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  3cdaa76d_ae5c_6ba4_ecc0_e40721db86bf["CheckInstructionsAgainstScopesVisitor"]
  01cf585d_2384_4412_6dde_8416d27772a6["AssertScopeInstructionsWithinScope.ts"]
  3cdaa76d_ae5c_6ba4_ecc0_e40721db86bf -->|defined in| 01cf585d_2384_4412_6dde_8416d27772a6
  0338496c_85f2_4fe4_8d22_e220ac6900fc["visitPlace()"]
  3cdaa76d_ae5c_6ba4_ecc0_e40721db86bf -->|method| 0338496c_85f2_4fe4_8d22_e220ac6900fc
  9fc7fdf4_abfa_797a_b6da_ccacce3f1f14["visitScope()"]
  3cdaa76d_ae5c_6ba4_ecc0_e40721db86bf -->|method| 9fc7fdf4_abfa_797a_b6da_ccacce3f1f14

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AssertScopeInstructionsWithinScope.ts lines 62–97

class CheckInstructionsAgainstScopesVisitor extends ReactiveFunctionVisitor<
  Set<ScopeId>
> {
  activeScopes: Set<ScopeId> = new Set();

  override visitPlace(
    id: InstructionId,
    place: Place,
    state: Set<ScopeId>,
  ): void {
    const scope = getPlaceScope(id, place);
    if (
      scope !== null &&
      // is there a scope for this at all, or did we end up pruning this scope?
      state.has(scope.id) &&
      /*
       * if the scope exists somewhere, it must be active or else this is a straggler
       * instruction
       */
      !this.activeScopes.has(scope.id)
    ) {
      CompilerError.invariant(false, {
        reason:
          'Encountered an instruction that should be part of a scope, but where that scope has already completed',
        description: `Instruction [${id}] is part of scope @${scope.id}, but that scope has already completed`,
        loc: place.loc,
      });
    }
  }

  override visitScope(block: ReactiveScopeBlock, state: Set<ScopeId>): void {
    this.activeScopes.add(block.scope.id);
    this.traverseScope(block, state);
    this.activeScopes.delete(block.scope.id);
  }
}

Domain

Frequently Asked Questions

What is the CheckInstructionsAgainstScopesVisitor class?
CheckInstructionsAgainstScopesVisitor is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AssertScopeInstructionsWithinScope.ts.
Where is CheckInstructionsAgainstScopesVisitor defined?
CheckInstructionsAgainstScopesVisitor is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/AssertScopeInstructionsWithinScope.ts at line 62.

Analyze Your Own Codebase

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

Try Supermodel Free