Package com.google.javascript.jscomp
Class J2clEqualitySameRewriterPass
- java.lang.Object
-
- com.google.javascript.jscomp.J2clEqualitySameRewriterPass
-
public class J2clEqualitySameRewriterPass extends java.lang.ObjectAn optimization pass to re-write J2CL Equality.$same.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanareNodesEqualForInlining(Node n1, Node n2)Are the nodes equal for the purpose of inlining? If type aware optimizations are on, type equality is checked.protected voiddeleteNode(Node property)protected CodingConventiongetCodingConvention()Returns the current coding convention.protected java.math.BigIntegergetSideEffectFreeBigIntValue(Node n)Returns the bigint value of the node if it has one and it cannot have side effects.protected TrigetSideEffectFreeBooleanValue(Node n)Calculate the known boolean value for a node if possible and if it has no side effects.protected java.lang.DoublegetSideEffectFreeNumberValue(Node n)Returns the number value of the node if it has one and it cannot have side effects.protected java.lang.StringgetSideEffectFreeStringValue(Node n)Gets the value of a node as a String, ornullif it cannot be converted.protected booleanisASTNormalized()Is the current AST normalized? (e.g.protected booleanisEcmaScript5OrGreater()Returns whether the output language is ECMAScript 5 or later.protected voidmarkFunctionsDeleted(Node function)protected voidmarkNewScopesChanged(Node n)protected booleanmayEffectMutableState(Node n)Returns whether the node may create new mutable state, or change existing state.protected booleanmayHaveSideEffects(Node n)Returns whether the node may have side effects when executed.protected booleannodeTypeMayHaveSideEffects(Node n)Returns true if the current node's type implies side effects.protected voidreport(DiagnosticType diagnostic, Node n)Helper method for reporting an error to the compiler when applying a peephole optimization.protected voidreportChangeToEnclosingScope(Node n)
-
-
-
Method Detail
-
report
protected void report(DiagnosticType diagnostic, Node n)
Helper method for reporting an error to the compiler when applying a peephole optimization.- Parameters:
diagnostic- The error typen- The node for which the error should be reported
-
areNodesEqualForInlining
protected boolean areNodesEqualForInlining(Node n1, Node n2)
Are the nodes equal for the purpose of inlining? If type aware optimizations are on, type equality is checked.
-
isASTNormalized
protected boolean isASTNormalized()
Is the current AST normalized? (e.g. has the Normalize pass been run and has the Denormalize pass not yet been run?)
-
mayEffectMutableState
protected boolean mayEffectMutableState(Node n)
Returns whether the node may create new mutable state, or change existing state.
-
mayHaveSideEffects
protected boolean mayHaveSideEffects(Node n)
Returns whether the node may have side effects when executed.
-
getSideEffectFreeNumberValue
protected java.lang.Double getSideEffectFreeNumberValue(Node n)
Returns the number value of the node if it has one and it cannot have side effects.Returns
nullotherwise.
-
getSideEffectFreeBigIntValue
protected java.math.BigInteger getSideEffectFreeBigIntValue(Node n)
Returns the bigint value of the node if it has one and it cannot have side effects.Returns
nullotherwise.
-
getSideEffectFreeStringValue
protected java.lang.String getSideEffectFreeStringValue(Node n)
Gets the value of a node as a String, ornullif it cannot be converted.This method effectively emulates the
String()JavaScript cast function when possible and the node has no side effects. Otherwise, it returnsnull.
-
getSideEffectFreeBooleanValue
protected Tri getSideEffectFreeBooleanValue(Node n)
Calculate the known boolean value for a node if possible and if it has no side effects.Returns
Tri.UNKNOWNif the node has side effects or its value cannot be statically determined.
-
nodeTypeMayHaveSideEffects
protected boolean nodeTypeMayHaveSideEffects(Node n)
Returns true if the current node's type implies side effects.This is a non-recursive version of the may have side effects check; used to check wherever the current node's type is one of the reason's why a subtree has side effects.
-
isEcmaScript5OrGreater
protected boolean isEcmaScript5OrGreater()
Returns whether the output language is ECMAScript 5 or later. Workarounds for quirks in browsers that do not support ES5 can be ignored when this is true.
-
getCodingConvention
protected CodingConvention getCodingConvention()
Returns the current coding convention.
-
reportChangeToEnclosingScope
protected final void reportChangeToEnclosingScope(Node n)
-
deleteNode
protected final void deleteNode(Node property)
-
markFunctionsDeleted
protected final void markFunctionsDeleted(Node function)
-
markNewScopesChanged
protected final void markNewScopesChanged(Node n)
-
-