final class PeepholeCollectPropertyAssignments extends AbstractPeepholeOptimization
E.g. var a = [];a[0] = 0
is optimized to var a = [0]
and
similarly for the object constructor.
Constructor and Description |
---|
PeepholeCollectPropertyAssignments() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
collectArrayProperty(Node arrayLiteral,
Node propertyCandidate) |
private static boolean |
collectObjectProperty(Node objectLiteral,
Node propertyCandidate) |
private boolean |
collectProperty(Node propertyCandidate,
java.lang.String name,
Node value) |
private static Node |
getName(Node n) |
private static Node |
getValue(Node n) |
(package private) static boolean |
isInterestingValue(Node n) |
private static boolean |
isPropertyAssignmentToName(Node propertyCandidate) |
private static boolean |
mightContainForwardReference(Node node,
java.lang.String varName) |
(package private) Node |
optimizeSubtree(Node subtree)
Given a node to optimize and a traversal, optimize the node.
|
areDeclaredGlobalExternsOnWindow, areNodesEqualForInlining, beginTraversal, endTraversal, getCodingConvention, isASTNormalized, isEcmaScript5OrGreater, mayEffectMutableState, mayHaveSideEffects, nodeTypeMayHaveSideEffects, report, reportCodeChange
Node optimizeSubtree(Node subtree)
AbstractPeepholeOptimization
optimizeSubtree
in class AbstractPeepholeOptimization
subtree
- The subtree that will be optimized.subtree
.static boolean isInterestingValue(Node n)
private static boolean isPropertyAssignmentToName(Node propertyCandidate)
private boolean collectProperty(Node propertyCandidate, java.lang.String name, Node value)
private static boolean collectArrayProperty(Node arrayLiteral, Node propertyCandidate)
private static boolean collectObjectProperty(Node objectLiteral, Node propertyCandidate)
private static boolean mightContainForwardReference(Node node, java.lang.String varName)