Home / Function/ printAliasingEffect() — react Function Reference

printAliasingEffect() — react Function Reference

Architecture documentation for the printAliasingEffect() function in PrintHIR.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  3892e473_17c5_bb0e_5d49_0b377b5ed784["printAliasingEffect()"]
  6976a9ee_9d8e_4f16_3016_495f39aff2fd["PrintHIR.ts"]
  3892e473_17c5_bb0e_5d49_0b377b5ed784 -->|defined in| 6976a9ee_9d8e_4f16_3016_495f39aff2fd
  6ae8909a_516f_2d5f_3f81_c2efe39bf321["printAliasingSignature()"]
  6ae8909a_516f_2d5f_3f81_c2efe39bf321 -->|calls| 3892e473_17c5_bb0e_5d49_0b377b5ed784
  f255dd41_8c48_19a9_1bcc_8efd2d663f32["applySignature()"]
  f255dd41_8c48_19a9_1bcc_8efd2d663f32 -->|calls| 3892e473_17c5_bb0e_5d49_0b377b5ed784
  7cb90dd3_dbe0_0087_670d_277ddeadabfc["applyEffect()"]
  7cb90dd3_dbe0_0087_670d_277ddeadabfc -->|calls| 3892e473_17c5_bb0e_5d49_0b377b5ed784
  767c7f7a_dd53_8c11_bc50_8150db33d98a["printPlaceForAliasEffect()"]
  3892e473_17c5_bb0e_5d49_0b377b5ed784 -->|calls| 767c7f7a_dd53_8c11_bc50_8150db33d98a
  6ae8909a_516f_2d5f_3f81_c2efe39bf321["printAliasingSignature()"]
  3892e473_17c5_bb0e_5d49_0b377b5ed784 -->|calls| 6ae8909a_516f_2d5f_3f81_c2efe39bf321
  d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"]
  3892e473_17c5_bb0e_5d49_0b377b5ed784 -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6
  style 3892e473_17c5_bb0e_5d49_0b377b5ed784 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts lines 931–1007

export function printAliasingEffect(effect: AliasingEffect): string {
  switch (effect.kind) {
    case 'Assign': {
      return `Assign ${printPlaceForAliasEffect(effect.into)} = ${printPlaceForAliasEffect(effect.from)}`;
    }
    case 'Alias': {
      return `Alias ${printPlaceForAliasEffect(effect.into)} <- ${printPlaceForAliasEffect(effect.from)}`;
    }
    case 'MaybeAlias': {
      return `MaybeAlias ${printPlaceForAliasEffect(effect.into)} <- ${printPlaceForAliasEffect(effect.from)}`;
    }
    case 'Capture': {
      return `Capture ${printPlaceForAliasEffect(effect.into)} <- ${printPlaceForAliasEffect(effect.from)}`;
    }
    case 'ImmutableCapture': {
      return `ImmutableCapture ${printPlaceForAliasEffect(effect.into)} <- ${printPlaceForAliasEffect(effect.from)}`;
    }
    case 'Create': {
      return `Create ${printPlaceForAliasEffect(effect.into)} = ${effect.value}`;
    }
    case 'CreateFrom': {
      return `Create ${printPlaceForAliasEffect(effect.into)} = kindOf(${printPlaceForAliasEffect(effect.from)})`;
    }
    case 'CreateFunction': {
      return `Function ${printPlaceForAliasEffect(effect.into)} = Function captures=[${effect.captures.map(printPlaceForAliasEffect).join(', ')}]`;
    }
    case 'Apply': {
      const receiverCallee =
        effect.receiver.identifier.id === effect.function.identifier.id
          ? printPlaceForAliasEffect(effect.receiver)
          : `${printPlaceForAliasEffect(effect.receiver)}.${printPlaceForAliasEffect(effect.function)}`;
      const args = effect.args
        .map(arg => {
          if (arg.kind === 'Identifier') {
            return printPlaceForAliasEffect(arg);
          } else if (arg.kind === 'Hole') {
            return ' ';
          }
          return `...${printPlaceForAliasEffect(arg.place)}`;
        })
        .join(', ');
      let signature = '';
      if (effect.signature != null) {
        if (effect.signature.aliasing != null) {
          signature = printAliasingSignature(effect.signature.aliasing);
        } else {
          signature = JSON.stringify(effect.signature, null, 2);
        }
      }
      return `Apply ${printPlaceForAliasEffect(effect.into)} = ${receiverCallee}(${args})${signature != '' ? '\n     ' : ''}${signature}`;
    }
    case 'Freeze': {
      return `Freeze ${printPlaceForAliasEffect(effect.value)} ${effect.reason}`;
    }
    case 'Mutate':
    case 'MutateConditionally':
    case 'MutateTransitive':
    case 'MutateTransitiveConditionally': {
      return `${effect.kind} ${printPlaceForAliasEffect(effect.value)}${effect.kind === 'Mutate' && effect.reason?.kind === 'AssignCurrentProperty' ? ' (assign `.current`)' : ''}`;
    }
    case 'MutateFrozen': {
      return `MutateFrozen ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
    }
    case 'MutateGlobal': {
      return `MutateGlobal ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
    }
    case 'Impure': {
      return `Impure ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
    }
    case 'Render': {
      return `Render ${printPlaceForAliasEffect(effect.place)}`;
    }
    default: {
      assertExhaustive(effect, `Unexpected kind '${(effect as any).kind}'`);
    }
  }
}

Subdomains

Frequently Asked Questions

What does printAliasingEffect() do?
printAliasingEffect() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts.
Where is printAliasingEffect() defined?
printAliasingEffect() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts at line 931.
What does printAliasingEffect() call?
printAliasingEffect() calls 3 function(s): assertExhaustive, printAliasingSignature, printPlaceForAliasEffect.
What calls printAliasingEffect()?
printAliasingEffect() is called by 3 function(s): applyEffect, applySignature, printAliasingSignature.

Analyze Your Own Codebase

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

Try Supermodel Free