Пример #1
0
 @Override
 public Void visitCompilationUnit(CompilationUnit node) {
   ScriptTag scriptTag = node.getScriptTag();
   NodeList<Directive> directives = node.getDirectives();
   visit(scriptTag);
   String prefix = scriptTag == null ? "" : " ";
   visitList(prefix, directives, " ");
   prefix = scriptTag == null && directives.isEmpty() ? "" : " ";
   visitList(prefix, node.getDeclarations(), " ");
   return null;
 }
Пример #2
0
 @Override
 public void evict(NodeList<Object> t1) {
   long now = scheduler.now();
   while (!t1.isEmpty()) {
     NodeList.Node<Object> n = t1.head.next;
     if (test(n.value, now)) {
       t1.removeFirst();
     } else {
       break;
     }
   }
 }
Пример #3
0
  /*
   * Finds all sources in graphNodes and adds them to the sL NodeList.
   */
  private void findSources(NodeList children) {
    NodeList sources = new NodeList();
    findInitialSources(children, sources);
    while (!sources.isEmpty()) {
      Node source = sources.getNode(sources.size() - 1);
      sL.add(source);
      sources.remove(source);
      removeSource(source, sources);

      // Check to see if the removal has made the parent node a source
      if (source.getParent() != null) {
        Node parent = source.getParent();
        setChildCount(parent, getChildCount(parent) - 1);
        if (isSource(parent) && canBeRemoved(parent)) {
          sources.add(parent);
          parent.flag = true;
        }
      }
    }
  }
Пример #4
0
  /*
   * Execution of the modified greedy cycle removal algorithm.
   */
  private void cycleRemove(NodeList children) {
    NodeList sR = new NodeList();
    do {
      findSinks(children, sR);
      findSources(children);

      // all sinks and sources added, find node with highest
      // outDegree - inDegree
      Node max = findNodeWithMaxDegree(children);
      if (max != null) {
        for (int i = 0; i < children.size(); i++) {
          Node child = (Node) children.get(i);
          if (child.flag) continue;
          if (child == max) restoreSinks(max, sR);
          else restoreSources(child);
        }
        remove(max);
      }
    } while (!allFlagged(children));
    while (!sR.isEmpty()) sL.add(sR.remove(sR.size() - 1));
  }
Пример #5
0
  /*
   * Finds all sinks in graphNodes and adds them to the passed NodeList
   */
  private void findSinks(NodeList children, NodeList rightList) {
    //	NodeList rightList = new NodeList();
    NodeList sinks = new NodeList();
    findInitialSinks(children, sinks);
    while (!sinks.isEmpty()) {
      Node sink = sinks.getNode(sinks.size() - 1);
      rightList.add(sink);
      sinks.remove(sink);
      removeSink(sink, sinks);

      // Check to see if the removal has made the parent node a sink
      if (sink.getParent() != null) {
        Node parent = sink.getParent();
        setChildCount(parent, getChildCount(parent) - 1);
        if (isSink(parent) && canBeRemoved(parent)) {
          sinks.add(parent);
          parent.flag = true;
        }
      }
    }
  }