Home / Class/ PostDominator Class — react Architecture

PostDominator Class — react Architecture

Architecture documentation for the PostDominator class in Dominator.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  0732b54e_6e75_2208_9742_addaecfa3581["PostDominator"]
  b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa["Dominator.ts"]
  0732b54e_6e75_2208_9742_addaecfa3581 -->|defined in| b02a9daf_aca4_b66a_9b9b_0b739a8ca4aa
  5a683135_1ee3_4fdc_1da4_028d903e8516["constructor()"]
  0732b54e_6e75_2208_9742_addaecfa3581 -->|method| 5a683135_1ee3_4fdc_1da4_028d903e8516
  4f787ebd_f91a_0ffe_de91_a5caecc9027f["exit()"]
  0732b54e_6e75_2208_9742_addaecfa3581 -->|method| 4f787ebd_f91a_0ffe_de91_a5caecc9027f
  a90edee2_35a1_577c_a329_5f6319fef1d4["get()"]
  0732b54e_6e75_2208_9742_addaecfa3581 -->|method| a90edee2_35a1_577c_a329_5f6319fef1d4
  b70b1e4a_ebd7_aa9b_2a48_145ebff98997["debug()"]
  0732b54e_6e75_2208_9742_addaecfa3581 -->|method| b70b1e4a_ebd7_aa9b_2a48_145ebff98997

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.ts lines 108–145

export class PostDominator<T> {
  #exit: T;
  #nodes: Map<T, T>;

  constructor(exit: T, nodes: Map<T, T>) {
    this.#exit = exit;
    this.#nodes = nodes;
  }

  // Returns the node representing normal exit from the function, ie return terminals.
  get exit(): T {
    return this.#exit;
  }

  /*
   * Returns the immediate dominator of the block with @param id if present. Returns null
   * if there is no immediate dominator (ie if the dominator is @param id itself).
   */
  get(id: T): T | null {
    const dominator = this.#nodes.get(id);
    CompilerError.invariant(dominator !== undefined, {
      reason: 'Unknown node',
      loc: GeneratedSource,
    });
    return dominator === id ? null : dominator;
  }

  debug(): string {
    const postDominators = new Map();
    for (const [key, value] of this.#nodes) {
      postDominators.set(`bb${key}`, `bb${value}`);
    }
    return prettyFormat({
      exit: `bb${this.exit}`,
      postDominators,
    });
  }
}

Frequently Asked Questions

What is the PostDominator class?
PostDominator is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.ts.
Where is PostDominator defined?
PostDominator is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/Dominator.ts at line 108.

Analyze Your Own Codebase

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

Try Supermodel Free