Class AmbiguateProperties

  • All Implemented Interfaces:
    CompilerPass

    public class AmbiguateProperties
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      AmbiguateProperties​(AbstractCompiler compiler, char[] reservedFirstCharacters, char[] reservedNonFirstCharacters, java.util.Set<java.lang.String> externProperties)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void process​(Node externs, Node root)
      Process the JS with root node root.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AmbiguateProperties

        public AmbiguateProperties​(AbstractCompiler compiler,
                                   char[] reservedFirstCharacters,
                                   char[] reservedNonFirstCharacters,
                                   java.util.Set<java.lang.String> externProperties)
    • Method Detail

      • 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