Class ParenthesizeFunctionsInChunks

  • All Implemented Interfaces:
    CompilerPass

    public final class ParenthesizeFunctionsInChunks
    extends java.lang.Object
    implements CompilerPass
    Marks all functions of specified chunks for eager parsing by adding the node property Node.MARK_FOR_PARENTHESIZE, which will wrap the fn in ().

    For non function expressions, we re-write the expression as follows:

    • Before: function foo() { ... }
    • After: var foo = (function() { ... })

    A log file is created 'eager_compile_chunks.log' with output on how many functions were marked for eager compile for each specified chunk.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void process​(Node externs, Node root)
      Process the JS with root node root.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParenthesizeFunctionsInChunks

        public ParenthesizeFunctionsInChunks​(AbstractCompiler compiler,
                                             java.util.Set<java.lang.String> parenthesizeFunctionsInChunks)
    • 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