Beispiel #1
0
    public void visit(NodeTraversal t, Node n, Node parent) {
      if (n.getType() == Token.FUNCTION) {
        Node functionNameNode = n.getFirstChild();
        String functionName = functionNameNode.getString();

        Node enclosingFunction = t.getEnclosingFunction();

        functionMap.put(n, new FunctionRecord(nextId, enclosingFunction, functionName));
        nextId++;
      }
    }
 private boolean targetSizeAfterInlineExceedsLimit(NodeTraversal t, FunctionState fs) {
   Node containingFunction = t.getEnclosingFunction();
   // Always inline at the top level,
   // unless maybeAddFunction has marked fs as not inlinable.
   if (containingFunction == null) {
     return false;
   }
   Node inlinedFun = fs.getFn().getFunctionNode();
   if (isAlwaysInlinable(inlinedFun)) {
     return false;
   }
   int inlinedFunSize =
       NodeUtil.countAstSizeUpToLimit(NodeUtil.getFunctionBody(inlinedFun), maxSizeAfterInlining);
   int targetFunSize = NodeUtil.countAstSizeUpToLimit(containingFunction, maxSizeAfterInlining);
   return inlinedFunSize + targetFunSize > maxSizeAfterInlining;
 }