void moveExpression ( Node expression ) { // TODO(johnlenz): This is not currently used by the function inliner, // as moving the call out of the expression before the actual function call // causes additional variables to be introduced. As the variable // inliner is improved, this might be a viable option. String resultName = getResultValueName ( ) ; Node injectionPoint = findInjectionPoint ( expression ) ; checkNotNull ( injectionPoint ) ; Node injectionPointParent = injectionPoint . getParent ( ) ; checkNotNull ( injectionPointParent ) ; checkState ( NodeUtil . isStatementBlock ( injectionPointParent ) ) ; // Replace the expression with a reference to the new name. Node expressionParent = expression . getParent ( ) ; expressionParent . replaceChild ( expression , withType ( IR . name ( resultName ) , expression . getJSType ( ) ) ) ; // Re-add the expression at the appropriate place. Node newExpressionRoot = NodeUtil . newVarNode ( resultName , expression ) ; newExpressionRoot . getFirstChild ( ) . setJSType ( expression . getJSType ( ) ) ; injectionPointParent . addChildBefore ( newExpressionRoot , injectionPoint ) ; compiler . reportChangeToEnclosingScope ( injectionPointParent ) ; }
Extract the specified expression from its parent expression .