private static void fixUninitializedVarDeclarations ( Node n , Node containingBlock ) { // Inner loop structure must already have logic to initialize its // variables. In particular FOR-IN structures must not be modified. if ( NodeUtil . isLoopStructure ( n ) ) { return ; } if ( ( n . isVar ( ) || n . isLet ( ) ) && n . hasOneChild ( ) ) { Node name = n . getFirstChild ( ) ; // It isn't initialized. if ( ! name . hasChildren ( ) ) { Node srcLocation = name ; name . addChildToBack ( NodeUtil . newUndefinedNode ( srcLocation ) ) ; containingBlock . addChildToFront ( n . detach ( ) ) ; } return ; } for ( Node c = n . getFirstChild ( ) ; c != null ; c = c . getNext ( ) ) { fixUninitializedVarDeclarations ( c , containingBlock ) ; } }
For all VAR node with uninitialized declarations set the values to be undefined .