Home / Class/ AliasingState Class — react Architecture

AliasingState Class — react Architecture

Architecture documentation for the AliasingState class in InferMutationAliasingRanges.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77["AliasingState"]
  99c95040_9e14_265b_aae3_b58b12a70d8d["InferMutationAliasingRanges.ts"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|defined in| 99c95040_9e14_265b_aae3_b58b12a70d8d
  5d4e4d78_c36a_0635_7ac7_b280e427ea93["create()"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|method| 5d4e4d78_c36a_0635_7ac7_b280e427ea93
  fba5b87c_4f97_a713_10e1_65cc2cf8d8ea["createFrom()"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|method| fba5b87c_4f97_a713_10e1_65cc2cf8d8ea
  74920f87_fc03_df5c_ac10_8ca6db32d279["capture()"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|method| 74920f87_fc03_df5c_ac10_8ca6db32d279
  fd717f31_7e4c_313d_1581_4e6a2ea3ca85["assign()"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|method| fd717f31_7e4c_313d_1581_4e6a2ea3ca85
  2664d9ed_bf71_6603_1903_91e8305e45d4["maybeAlias()"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|method| 2664d9ed_bf71_6603_1903_91e8305e45d4
  a245d666_3ea2_209a_f47a_fe1e2c5a2577["render()"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|method| a245d666_3ea2_209a_f47a_fe1e2c5a2577
  cd8871a0_00ab_a3ba_98a3_61b6b75d973c["mutate()"]
  78bdc9d3_b80e_c93f_98e8_83b50c1b2b77 -->|method| cd8871a0_00ab_a3ba_98a3_61b6b75d973c

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingRanges.ts lines 595–839

class AliasingState {
  nodes: Map<Identifier, Node> = new Map();

  create(place: Place, value: Node['value']): void {
    this.nodes.set(place.identifier, {
      id: place.identifier,
      createdFrom: new Map(),
      captures: new Map(),
      aliases: new Map(),
      maybeAliases: new Map(),
      edges: [],
      transitive: null,
      local: null,
      lastMutated: 0,
      mutationReason: null,
      value,
    });
  }

  createFrom(index: number, from: Place, into: Place): void {
    this.create(into, {kind: 'Object'});
    const fromNode = this.nodes.get(from.identifier);
    const toNode = this.nodes.get(into.identifier);
    if (fromNode == null || toNode == null) {
      return;
    }
    fromNode.edges.push({index, node: into.identifier, kind: 'alias'});
    if (!toNode.createdFrom.has(from.identifier)) {
      toNode.createdFrom.set(from.identifier, index);
    }
  }

  capture(index: number, from: Place, into: Place): void {
    const fromNode = this.nodes.get(from.identifier);
    const toNode = this.nodes.get(into.identifier);
    if (fromNode == null || toNode == null) {
      return;
    }
    fromNode.edges.push({index, node: into.identifier, kind: 'capture'});
    if (!toNode.captures.has(from.identifier)) {
      toNode.captures.set(from.identifier, index);
    }
  }

  assign(index: number, from: Place, into: Place): void {
    const fromNode = this.nodes.get(from.identifier);
    const toNode = this.nodes.get(into.identifier);
    if (fromNode == null || toNode == null) {
      return;
    }
    fromNode.edges.push({index, node: into.identifier, kind: 'alias'});
    if (!toNode.aliases.has(from.identifier)) {
      toNode.aliases.set(from.identifier, index);
    }
  }

  maybeAlias(index: number, from: Place, into: Place): void {
    const fromNode = this.nodes.get(from.identifier);
    const toNode = this.nodes.get(into.identifier);
    if (fromNode == null || toNode == null) {
      return;
    }
    fromNode.edges.push({index, node: into.identifier, kind: 'maybeAlias'});
    if (!toNode.maybeAliases.has(from.identifier)) {
      toNode.maybeAliases.set(from.identifier, index);
    }
  }

  render(index: number, start: Identifier, errors: CompilerError): void {
    const seen = new Set<Identifier>();
    const queue: Array<Identifier> = [start];
    while (queue.length !== 0) {
      const current = queue.pop()!;
      if (seen.has(current)) {
        continue;
      }
      seen.add(current);
      const node = this.nodes.get(current);
      if (node == null || node.transitive != null || node.local != null) {
        continue;
      }

Domain

Frequently Asked Questions

What is the AliasingState class?
AliasingState is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingRanges.ts.
Where is AliasingState defined?
AliasingState is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingRanges.ts at line 595.

Analyze Your Own Codebase

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

Try Supermodel Free