src/com/google/javascript/jscomp/FunctionInjector.java
/**
   * Inline a function that fulfills the requirements of
   * canInlineReferenceDirectly into the call site, replacing only the CALL
   * node.
   */
Inline a function that fulfills the requirements of
canInlineReferenceDirectly into the call site, replacing only the CALL
node.
Inline a function that fulfills the requirements of canInlineReferenceDirectly into the call site replacing only the CALL node .
private Node inlineReturnValue(Reference ref, Node fnNode) {
    Node callNode = ref.callNode;
    Node block = fnNode.getLastChild();
    Node callParentNode = callNode.getParent();
    Map<String, Node> argMap =
        FunctionArgumentInjector.getFunctionCallParameterMap(
            fnNode, callNode, this.safeNameIdSupplier);
    Node newExpression;
    if (!block.hasChildren()) {
      Node srcLocation = block;
      newExpression = NodeUtil.newUndefinedNode(srcLocation);
    } else {
      Node returnNode = block.getFirstChild();
      checkArgument(returnNode.isReturn(), returnNode);
      Node safeReturnNode = returnNode.cloneTree();
      Node inlineResult = FunctionArgumentInjector.inject(
          null, safeReturnNode, null, argMap);
      checkArgument(safeReturnNode == inlineResult);
      newExpression = safeReturnNode.removeFirstChild();
      NodeUtil.markNewScopesChanged(newExpression, compiler);
    }
    JSType typeBeforeCast = callNode.getJSTypeBeforeCast();
    if (typeBeforeCast != null) {
      newExpression.setJSTypeBeforeCast(typeBeforeCast);
      newExpression.setJSType(callNode.getJSType());
    }
    callParentNode.replaceChild(callNode, newExpression);
    NodeUtil.markFunctionsDeleted(callNode, compiler);
    return newExpression;
  }
private Node inlineReturnValue ( Reference ref , Node fnNode ) { Node callNode = ref . callNode ; Node block = fnNode . getLastChild ( ) ; Node callParentNode = callNode . getParent ( ) ; Map < String , Node > argMap = FunctionArgumentInjector . getFunctionCallParameterMap ( fnNode , callNode , this . safeNameIdSupplier ) ; Node newExpression ; if ( ! block . hasChildren ( ) ) { Node srcLocation = block ; newExpression = NodeUtil . newUndefinedNode ( srcLocation ) ; } else { Node returnNode = block . getFirstChild ( ) ; checkArgument ( returnNode . isReturn ( ) , returnNode ) ; Node safeReturnNode = returnNode . cloneTree ( ) ; Node inlineResult = FunctionArgumentInjector . inject ( null , safeReturnNode , null , argMap ) ; checkArgument ( safeReturnNode == inlineResult ) ; newExpression = safeReturnNode . removeFirstChild ( ) ; NodeUtil . markNewScopesChanged ( newExpression , compiler ) ; } JSType typeBeforeCast = callNode . getJSTypeBeforeCast ( ) ; if ( typeBeforeCast != null ) { newExpression . setJSTypeBeforeCast ( typeBeforeCast ) ; newExpression . setJSType ( callNode . getJSType ( ) ) ; } callParentNode . replaceChild ( callNode , newExpression ) ; NodeUtil . markFunctionsDeleted ( callNode , compiler ) ; return newExpression ; }
Inline a function that fulfills the requirements of
 canInlineReferenceDirectly into the call site, replacing only the CALL
 node.
Inline a function that fulfills the requirements of canInlineReferenceDirectly into the call site replacing only the CALL node .
// NOTE: As the normalize pass guarantees globals aren't being // shadowed and an expression can't introduce new names, there is // no need to check for conflicts. // Create an argName -> expression map, checking for side effects. // Clone the return node first. // If the call site had a cast ensure it's persisted to the new expression that replaces it.