com.google.javascript.jscomp
Class OptimizeReturns

java.lang.Object
  extended by com.google.javascript.jscomp.OptimizeReturns
All Implemented Interfaces:
CompilerPass

public class OptimizeReturns
extends Object
implements CompilerPass

A compiler pass for optimize function return results. Currently this pass looks for results that are complete unused and rewrite then to be: "return x()" -->"x(); return" , but it can easily be expanded to look for use context to avoid unneed type coersion: - "return x.toString()" --> "return x" - "return !!x" --> "return x"


Method Summary
 void process(Node externs, Node root)
          Process the JS with root node root.
 void process(Node externs, Node root, com.google.javascript.jscomp.SimpleDefinitionFinder definitions)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 interface CompilerPass
Parameters:
externs - Top of external JS tree
root - Top of JS tree

process

public void process(Node externs,
                    Node root,
                    com.google.javascript.jscomp.SimpleDefinitionFinder definitions)