|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.javascript.jscomp.SpecializeModule.SpecializationState
public static class SpecializeModule.SpecializationState
A class to hold state during SpecializeModule. An instance of this class
is passed to specialization-aware compiler passes -- they use it to
communicate with SpecializeModule.
SpecializationAware optimizations are required to keep track of the
functions they remove and the functions that they modify so that the fixups
can be added. However, not all functions can be fixed up.
Specialization-aware classes *must* call
reportSpecializedFunction(com.google.javascript.rhino.Node)
when a function is modified during
specialization and reportRemovedFunction(com.google.javascript.rhino.Node, com.google.javascript.rhino.Node)
when one is removed.
Also, when specializing, they must query canFixupFunction(com.google.javascript.rhino.Node)
before modifying a function.
This two-way communication, is the reason we don't use
AstChangeProxy
to report code changes.
Constructor Summary | |
---|---|
SpecializeModule.SpecializationState(com.google.javascript.jscomp.SimpleFunctionAliasAnalysis initialModuleAliasAnalysis)
|
Method Summary | |
---|---|
boolean |
canFixupFunction(Node functionNode)
Returns true if the function can be fixed up (that is, if it can be safely removed or specialized). |
boolean |
canFixupSpecializedFunctionContainingNode(Node n)
Returns true if the function containing n can be fixed up. |
Set<Node> |
getRemovedFunctions()
The functions removed by this compiler pass. |
Set<Node> |
getSpecializedFunctions()
Returns the functions specialized by this compiler pass. |
void |
reportRemovedFunction(Node functionNode,
Node declaringBlock)
Reports that a function has been removed. |
void |
reportSpecializedFunction(Node functionNode)
Reports that a function has been specialized. |
void |
reportSpecializedFunctionContainingNode(Node node)
Reports that the function containing the node has been specialized. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SpecializeModule.SpecializationState(com.google.javascript.jscomp.SimpleFunctionAliasAnalysis initialModuleAliasAnalysis)
Method Detail |
---|
public Set<Node> getSpecializedFunctions()
public void reportSpecializedFunction(Node functionNode)
functionNode
- A specialized AST node with type Token.FUNCTIONpublic void reportSpecializedFunctionContainingNode(Node node)
public Set<Node> getRemovedFunctions()
public void reportRemovedFunction(Node functionNode, Node declaringBlock)
functionNode
- A removed AST node with type Token.FUNCTIONdeclaringBlock
- If the function declaration puts a variable in the
scope, we need to have a VAR statement in the scope where the
function is declared. Null if the function does not put a name
in the scope.public boolean canFixupFunction(Node functionNode)
In order to be safely fixed up, a function must be:
- in the global scope - not aliased in the initial module - of one of the following forms: function f() {} var f = function() {} f = function(){} var ns = {}; ns.f = function() {} SomeClass.prototype.foo = function() {};
Anonymous functions cannot be safely fixed up, nor can functions that have been aliased.
Some functions declared as object literals could be safely fixed up, however we do not currently support this.
public boolean canFixupSpecializedFunctionContainingNode(Node n)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |