final class ClosureOptimizePrimitives extends java.lang.Object implements CompilerPass
Compiler pass that converts all calls to: goog.object.create(key1, val1, key2, val2, ...) where all of the keys are literals into object literals.
| Modifier and Type | Class and Description |
|---|---|
private class |
ClosureOptimizePrimitives.FindObjectCreateCalls
Identifies all calls to goog.object.create.
|
| Modifier and Type | Field and Description |
|---|---|
private AbstractCompiler |
compiler
Reference to the JS compiler
|
| Constructor and Description |
|---|
ClosureOptimizePrimitives(AbstractCompiler compiler) |
| Modifier and Type | Method and Description |
|---|---|
private static boolean |
canOptimizeObjectCreate(Node firstParam)
Returns whether the given call to goog.object.create can be converted to an
object literal.
|
private static boolean |
canOptimizeObjectCreateSet(Node firstParam)
Returns whether the given call to goog.object.create can be converted to an
object literal.
|
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
private void |
processObjectCreateCall(Node callNode)
Converts all of the given call nodes to object literals that are safe to
do so.
|
private void |
processObjectCreateSetCall(Node callNode)
Converts all of the given call nodes to object literals that are safe to
do so.
|
private final AbstractCompiler compiler
ClosureOptimizePrimitives(AbstractCompiler compiler)
compiler - The AbstractCompilerpublic void process(Node externs, Node root)
CompilerPassprocess in interface CompilerPassexterns - Top of external JS treeroot - Top of JS treeprivate void processObjectCreateCall(Node callNode)
private static boolean canOptimizeObjectCreate(Node firstParam)
private void processObjectCreateSetCall(Node callNode)
private static boolean canOptimizeObjectCreateSet(Node firstParam)