private static Node makeNewRvalueForDestructuringKey ( Node stringKey , Node rvalue , Set < AstChange > newNodes , Ref ref ) { if ( stringKey . getOnlyChild ( ) . isDefaultValue ( ) ) { Node defaultValue = stringKey . getFirstChild ( ) . getSecondChild ( ) . detach ( ) ; // Assume `rvalue` has no side effects since it's a qname, and we can create multiple // references to it. This ignores getters/setters. Node rvalueForSheq = rvalue . cloneTree ( ) ; if ( newNodes != null ) { newNodes . add ( new AstChange ( ref . module , ref . scope , rvalueForSheq ) ) ; } // `void 0 === rvalue ? defaultValue : rvalue` rvalue = IR . hook ( IR . sheq ( NodeUtil . newUndefinedNode ( rvalue ) , rvalueForSheq ) , defaultValue , rvalue ) . srcrefTree ( defaultValue ) ; } return rvalue ; }
Makes a default value expression from the rvalue or otherwise just returns it