Class AmbiguateProperties

java.lang.Object
com.google.javascript.jscomp.disambiguate.AmbiguateProperties
All Implemented Interfaces:
CompilerPass

public class AmbiguateProperties extends Object implements CompilerPass
Renames unrelated properties to the same name, using Colors provided by the typechecker. This allows better compression as more properties can be given short names.

Properties are considered unrelated if they are never referenced from the same color or from a subtype of each others' colors, thus this pass is only effective if type checking is enabled.

Example: Foo.fooprop = 0; Foo.fooprop2 = 0; Bar.barprop = 0; becomes: Foo.a = 0; Foo.b = 0; Bar.a = 0;

  • Constructor Details

    • AmbiguateProperties

      public AmbiguateProperties(AbstractCompiler compiler, char[] reservedFirstCharacters, char[] reservedNonFirstCharacters, Set<String> externProperties)
  • Method Details

    • process

      public void process(Node externs, Node root)
      Description copied from interface: CompilerPass
      Process the JS with root node root. Can modify the contents of each Node tree
      Specified by:
      process in interface CompilerPass
      Parameters:
      externs - Top of external JS tree
      root - Top of JS tree