Class DisambiguateProperties
- java.lang.Object
-
- com.google.javascript.jscomp.disambiguate.DisambiguateProperties
-
- All Implemented Interfaces:
CompilerPass
public class DisambiguateProperties extends java.lang.Object implements CompilerPass
DisambiguateProperties renames properties to disambiguate between unrelated fields with the same name. Two properties are considered related if they share a definition on their prototype chains, or if they are potentially referenced together via union types.Renaming only occurs if there are two or more distinct properties with the same name.
This pass allows other passes, such as inlining and code removal to take advantage of type information implicitly.
Foo.a; Bar.a;
will become
Foo.Foo$a; Bar.Bar$a;
NOTE(dimvar): For every property, this pass groups together the types that can't be disambiguated. If a type inherits from another type, their common properties can never be disambiguated, yet we have to compute this info once per property rather than just once in the pass. This is where the bulk of the time is spent. We have added many caches that help a lot, but it is probably worth it to revisit this pass and rewrite it in a way that does not compute the same thing over and over.
-
-
Constructor Summary
Constructors Constructor Description DisambiguateProperties(AbstractCompiler compiler, java.util.Map<java.lang.String,CheckLevel> propertiesToErrorFor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.google.javascript.jscomp.disambiguate.DisambiguateProperties.Property
getProperty(java.lang.String name)
Returns the property for the given name, creating it if necessary.void
process(Node externs, Node root)
Process the JS with root node root.
-
-
-
Constructor Detail
-
DisambiguateProperties
public DisambiguateProperties(AbstractCompiler compiler, java.util.Map<java.lang.String,CheckLevel> propertiesToErrorFor)
-
-
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 interfaceCompilerPass
- Parameters:
externs
- Top of external JS treeroot
- Top of JS tree
-
getProperty
protected com.google.javascript.jscomp.disambiguate.DisambiguateProperties.Property getProperty(java.lang.String name)
Returns the property for the given name, creating it if necessary.
-
-