• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DiGraphNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.javascript.jscomp.graph.DiGraph.DiGraphNode的典型用法代码示例。如果您正苦于以下问题:Java DiGraphNode类的具体用法?Java DiGraphNode怎么用?Java DiGraphNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DiGraphNode类属于com.google.javascript.jscomp.graph.DiGraph包,在下文中一共展示了DiGraphNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initialize

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
@Override
protected void initialize() {
  orderedWorkSet.clear();
  for (DiGraphNode<N, Branch> node : getCfg().getDirectedGraphNodes()) {
    List<DiGraphEdge<N, Branch>> edgeList =
      getCfg().getOutEdges(node.getValue());
    int outEdgeCount = edgeList.size();
    List<L> outLattices = Lists.newArrayList();
    for (int i = 0; i < outEdgeCount; i++) {
      outLattices.add(createInitialEstimateLattice());
    }
    node.setAnnotation(new BranchedFlowState<L>(
        createInitialEstimateLattice(), outLattices));
    if (node != getCfg().getImplicitReturn()) {
      orderedWorkSet.add(node);
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:DataFlowAnalysis.java


示例2: joinInputs

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
@Override
protected void joinInputs(DiGraphNode<N, Branch> node) {
  BranchedFlowState<L> state = node.getAnnotation();
  List<DiGraphNode<N, Branch>> predNodes =
      getCfg().getDirectedPredNodes(node);
  List<L> values = new ArrayList<L>(predNodes.size());

  for (DiGraphNode<N, Branch> predNode : predNodes) {
    BranchedFlowState<L> predNodeState = predNode.getAnnotation();

    L in = predNodeState.out.get(
        getCfg().getDirectedSuccNodes(predNode).indexOf(node));

    values.add(in);
  }
  if (getCfg().getEntry() == node) {
    state.setIn(createEntryLattice());
  } else if (!values.isEmpty()) {
    state.setIn(joinOp.apply(values));
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:22,代码来源:DataFlowAnalysis.java


示例3: allPathsReturn

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * @returns true if all paths from block must exit with an explicit return.
 */
private boolean allPathsReturn(Node block) {
  // Computes the control flow graph.
  ControlFlowAnalysis cfa = new ControlFlowAnalysis(compiler, false);
  cfa.process(null, block);
  ControlFlowGraph<Node> cfg = cfa.getCfg();

  Node returnPathsParent = cfg.getImplicitReturn().getValue();
  for (DiGraphNode<Node, Branch> pred :
    cfg.getDirectedPredNodes(returnPathsParent)) {
    Node n = pred.getValue();
    if (n.getType() != Token.RETURN) {
      return false;
    }
  }
  return true;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:InstrumentFunctions.java


示例4: CheckPathsBetweenNodes

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Given a graph G with nodes A and B, this algorithm determines if all paths
 * from A to B contain at least one node satisfying a given predicate.
 *
 * Note that nodePredicate is not necessarily called for all nodes in G nor is
 * edgePredicate called for all edges in G.
 *
 * @param graph Graph G to analyze.
 * @param a The node A.
 * @param b The node B.
 * @param nodePredicate Predicate which at least one node on each path from an
 *     A node to B (inclusive) must match.
 * @param edgePredicate Edges to consider as part of the graph. Edges in
 *     graph that don't match edgePredicate will be ignored.
 */
CheckPathsBetweenNodes(DiGraph<N, E> graph, DiGraphNode<N, E> a,
    DiGraphNode<N, E> b, Predicate<N> nodePredicate,
    Predicate<DiGraphEdge<N, E>> edgePredicate) {
  this.nodePredicate = nodePredicate;
  this.edgePredicate = edgePredicate;

  graph.pushNodeAnnotations();
  graph.pushEdgeAnnotations();

  discoverBackEdges(a);
  result = checkAllPathsWithoutBackEdges(a, b);

  graph.popNodeAnnotations();
  graph.popEdgeAnnotations();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:31,代码来源:CheckPathsBetweenNodes.java


示例5: checkAllPathsWithoutBackEdges

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Verify that all non-looping paths from {@code a} to {@code b} pass
 * through at least one node where {@code nodePredicate} is true.
 */
private boolean checkAllPathsWithoutBackEdges(DiGraphNode<N, E> a,
    DiGraphNode<N, E> b) {
  if (nodePredicate.apply(a.getValue())) {
    return true;
  }
  if (a == b) {
    return false;
  }
  for (DiGraphEdge<N, E> e : a.getOutEdges()) {
    if (ignoreEdge(e)) {
      continue;
    }
    if (e.getAnnotation() == BACK_EDGE) {
      continue;
    }
    DiGraphNode<N, E> next = e.getDestination();
    if (!checkAllPathsWithoutBackEdges(next, b)) {
      return false;
    }
  }
  return true;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:27,代码来源:CheckPathsBetweenNodes.java


示例6: process

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
@Override
public void process(Node externs, Node root) {
  if (nameGraph == null) {
    NameReferenceGraphConstruction c =
        new NameReferenceGraphConstruction(compiler);
    c.process(externs, root);
    nameGraph = c.getNameReferenceGraph();
  }
  
  for (DiGraphNode<Name, Reference> node : 
      nameGraph.getDirectedGraphNodes()) {
    Name name = node.getValue();
    if (name.canChangeSignature()) {
      List<DiGraphEdge<Name, Reference>> edges = node.getInEdges();        
      tryEliminateConstantArgs(name, edges);
      tryEliminateOptionalArgs(name, edges);
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:OptimizeParameters.java


示例7: prioritizeFromEntryNode

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Given an entry node, find all the nodes reachable from that node
 * and prioritize them.
 */
private void prioritizeFromEntryNode(DiGraphNode<Node, Branch> entry) {
  PriorityQueue<DiGraphNode<Node, Branch>> worklist =
      new PriorityQueue<DiGraphNode<Node, Branch>>(10, priorityComparator);
  worklist.add(entry);

  while (!worklist.isEmpty()) {
    DiGraphNode<Node, Branch> current = worklist.remove();
    if (nodePriorities.containsKey(current)) {
      continue;
    }

    nodePriorities.put(current, ++priorityCounter);

    List<DiGraphNode<Node, Branch>> successors =
        cfg.getDirectedSuccNodes(current);
    for (DiGraphNode<Node, Branch> candidate : successors) {
      worklist.add(candidate);
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:ControlFlowAnalysis.java


示例8: testManyValidPaths

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/** Tests a graph with many valid paths. */
public void testManyValidPaths() {
  DiGraph<String, String> g = new LinkedDirectedGraph<String, String>();
  g.createDirectedGraphNode("a");
  g.createDirectedGraphNode("b");
  g.createDirectedGraphNode("c1");
  g.createDirectedGraphNode("c2");
  g.createDirectedGraphNode("c3");
  DiGraphNode<String, String> d = g.createDirectedGraphNode("d");

  g.connect("a",  "-", "b");
  g.connect("b",  "-", "c1");
  g.connect("b",  "-", "c2");
  g.connect("c2", "-", "d");
  g.connect("c1", "-", "d");
  g.connect("a",  "-", "c3");
  g.connect("c3", "-", "d");

  assertGood(createTest(g, "a", "d", new PrefixPredicate("c"), ALL_EDGE));
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:21,代码来源:CheckPathsBetweenNodesTest.java


示例9: assertNodeOrder

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Asserts the priority order of CFG nodes.
 *
 * Checks that the node type of the highest-priority node matches the
 * first element of the list, the type of the second node matches the
 * second element of the list, and so on.
 *
 * @param cfg The control flow graph.
 * @param nodeTypes The expected node types, in order.
 */
private void assertNodeOrder(ControlFlowGraph<Node> cfg,
    List<Integer> nodeTypes) {
  List<DiGraphNode<Node, Branch>> cfgNodes = cfg.getDirectedGraphNodes();
  Collections.sort(cfgNodes, cfg.getOptionalNodeComparator(true));

  // IMPLICIT RETURN must always be last.
  Node implicitReturn = cfgNodes.remove(cfgNodes.size() - 1).getValue();
  assertNull(implicitReturn == null ? "null" : implicitReturn.toStringTree(),
      implicitReturn);

  assertEquals("Wrong number of CFG nodes",
      nodeTypes.size(), cfgNodes.size());
  for (int i = 0; i < cfgNodes.size(); i++) {
    int expectedType = nodeTypes.get(i);
    int actualType = cfgNodes.get(i).getValue().getType();
    assertEquals(
        "Node type mismatch at " + i + ".\n" +
        "found   : " + Token.name(actualType) + "\n" +
        "required: " + Token.name(expectedType) + "\n",
        expectedType, actualType);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:33,代码来源:ControlFlowAnalysisTest.java


示例10: compare

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
public int compare(DiGraphNode<Name, Reference> node1,
    DiGraphNode<Name, Reference> node2) {
  Preconditions.checkNotNull(node1.getValue());
  Preconditions.checkNotNull(node2.getValue());

  if ((node1.getValue().getQualifiedName() == null) &&
      (node2.getValue().getQualifiedName() == null)) {
    return 0;
  }

  // Node 1, if null, comes before node 2.
  if (node1.getValue().getQualifiedName() == null) {
    return -1;
  }

  // Node 2, if null, comes before node 1.
  if (node2.getValue().getQualifiedName() == null) {
    return 1;
  }

  return node1.getValue().getQualifiedName().compareTo(
      node2.getValue().getQualifiedName());
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:24,代码来源:NameReferenceGraphReport.java


示例11: initialize

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
@Override
protected void initialize() {
  orderedWorkSet.clear();
  for (DiGraphNode<N, Branch> node : getCfg().getDirectedGraphNodes()) {
    int outEdgeCount = getCfg().getOutEdges(node.getValue()).size();
    List<L> outLattices = Lists.newArrayList();
    for (int i = 0; i < outEdgeCount; i++) {
      outLattices.add(createInitialEstimateLattice());
    }
    node.setAnnotation(new BranchedFlowState<L>(
        createInitialEstimateLattice(), outLattices));
    if (node != getCfg().getImplicitReturn()) {
      orderedWorkSet.add(node);
    }
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:17,代码来源:DataFlowAnalysis.java


示例12: checkAllPathsWithoutBackEdges

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Verify that all non-looping paths from {@code a} to {@code b} pass
 * through at least one node where {@code nodePredicate} is true.
 */
private boolean checkAllPathsWithoutBackEdges(DiGraphNode<N, E> a,
    DiGraphNode<N, E> b) {
  if (nodePredicate.apply(a.getValue()) &&
      (inclusive || (a != start && a != end))) {
    return true;
  }
  if (a == b) {
    return false;
  }
  for (DiGraphEdge<N, E> e : a.getOutEdges()) {
    if (ignoreEdge(e)) {
      continue;
    }
    if (e.getAnnotation() == BACK_EDGE) {
      continue;
    }
    DiGraphNode<N, E> next = e.getDestination();
    if (!checkAllPathsWithoutBackEdges(next, b)) {
      return false;
    }
  }
  return true;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:28,代码来源:CheckPathsBetweenNodes.java


示例13: checkSomePathsWithoutBackEdges

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Verify that some non-looping paths from {@code a} to {@code b} pass
 * through at least one node where {@code nodePredicate} is true.
 */
private boolean checkSomePathsWithoutBackEdges(DiGraphNode<N, E> a,
    DiGraphNode<N, E> b) {
  if (nodePredicate.apply(a.getValue()) &&
      (inclusive || (a != start && a != end))) {
    return true;
  }
  if (a == b) {
    return false;
  }
  for (DiGraphEdge<N, E> e : a.getOutEdges()) {
    if (ignoreEdge(e)) {
      continue;
    }
    if (e.getAnnotation() == BACK_EDGE) {
      continue;
    }
    DiGraphNode<N, E> next = e.getDestination();
    if (checkSomePathsWithoutBackEdges(next, b)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:28,代码来源:CheckPathsBetweenNodes.java


示例14: process

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
@Override
public void process(Node externs, Node root) {
  if (nameGraph == null) {
    NameReferenceGraphConstruction c =
        new NameReferenceGraphConstruction(compiler);
    c.process(externs, root);
    nameGraph = c.getNameReferenceGraph();
  }

  for (DiGraphNode<Name, Reference> node :
      nameGraph.getDirectedGraphNodes()) {
    Name name = node.getValue();
    if (name.canChangeSignature()) {
      List<DiGraphEdge<Name, Reference>> edges = node.getInEdges();
      tryEliminateConstantArgs(name, edges);
      tryEliminateOptionalArgs(name, edges);
    }
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:20,代码来源:OptimizeParameters.java


示例15: assertNodeOrder

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Asserts the priority order of CFG nodes.
 *
 * Checks that the node type of the highest-priority node matches the
 * first element of the list, the type of the second node matches the
 * second element of the list, and so on.
 *
 * @param cfg The control flow graph.
 * @param nodeTypes The expected node types, in order.
 */
private void assertNodeOrder(ControlFlowGraph<Node> cfg,
    List<Integer> nodeTypes) {
  List<DiGraphNode<Node, Branch>> cfgNodes =
      Lists.newArrayList(cfg.getDirectedGraphNodes());
  Collections.sort(cfgNodes, cfg.getOptionalNodeComparator(true));

  // IMPLICIT RETURN must always be last.
  Node implicitReturn = cfgNodes.remove(cfgNodes.size() - 1).getValue();
  assertNull(implicitReturn == null ? "null" : implicitReturn.toStringTree(),
      implicitReturn);

  assertEquals("Wrong number of CFG nodes",
      nodeTypes.size(), cfgNodes.size());
  for (int i = 0; i < cfgNodes.size(); i++) {
    int expectedType = nodeTypes.get(i);
    int actualType = cfgNodes.get(i).getValue().getType();
    assertEquals(
        "Node type mismatch at " + i + ".\n" +
        "found   : " + Token.name(actualType) + "\n" +
        "required: " + Token.name(expectedType) + "\n",
        expectedType, actualType);
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:34,代码来源:ControlFlowAnalysisTest.java


示例16: visit

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  if (parent == null) {
    return;
  }
  if (n.isFunction() || n.isScript()) {
    return;
  }

  DiGraphNode<Node, Branch> gNode = cfg.getDirectedGraphNode(n);
  if (gNode == null) { // Not in CFG.
    return;
  }
  if (gNode.getAnnotation() != GraphReachability.REACHABLE ||
      (removeNoOpStatements && !NodeUtil.mayHaveSideEffects(n, compiler))) {
    removeDeadExprStatementSafely(n);
    return;
  }

  tryRemoveUnconditionalBranching(n);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:UnreachableCodeElimination.java


示例17: compare

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
@Override
public int compare(DiGraphNode<Name, Reference> node1,
    DiGraphNode<Name, Reference> node2) {
  Preconditions.checkNotNull(node1.getValue());
  Preconditions.checkNotNull(node2.getValue());

  if ((node1.getValue().getQualifiedName() == null) &&
      (node2.getValue().getQualifiedName() == null)) {
    return 0;
  }

  // Node 1, if null, comes before node 2.
  if (node1.getValue().getQualifiedName() == null) {
    return -1;
  }

  // Node 2, if null, comes before node 1.
  if (node2.getValue().getQualifiedName() == null) {
    return 1;
  }

  return node1.getValue().getQualifiedName().compareTo(
      node2.getValue().getQualifiedName());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:NameReferenceGraphReport.java


示例18: allPathsReturn

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * @returns true if all paths from block must exit with an explicit return.
 */
private boolean allPathsReturn(Node block) {
  // Computes the control flow graph.
  ControlFlowAnalysis cfa = new ControlFlowAnalysis(
      compiler, false, false);
  cfa.process(null, block);
  ControlFlowGraph<Node> cfg = cfa.getCfg();

  Node returnPathsParent = cfg.getImplicitReturn().getValue();
  for (DiGraphNode<Node, Branch> pred :
    cfg.getDirectedPredNodes(returnPathsParent)) {
    Node n = pred.getValue();
    if (!n.isReturn()) {
      return false;
    }
  }
  return true;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:InstrumentFunctions.java


示例19: testManyValidPaths

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/** Tests a graph with many valid paths. */
public void testManyValidPaths() {
  DiGraph<String, String> g = LinkedDirectedGraph.create();
  g.createDirectedGraphNode("a");
  g.createDirectedGraphNode("b");
  g.createDirectedGraphNode("c1");
  g.createDirectedGraphNode("c2");
  g.createDirectedGraphNode("c3");
  DiGraphNode<String, String> d = g.createDirectedGraphNode("d");

  g.connect("a",  "-", "b");
  g.connect("b",  "-", "c1");
  g.connect("b",  "-", "c2");
  g.connect("c2", "-", "d");
  g.connect("c1", "-", "d");
  g.connect("a",  "-", "c3");
  g.connect("c3", "-", "d");

  assertGood(createTest(g, "a", "d", new PrefixPredicate("c"), ALL_EDGE));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:CheckPathsBetweenNodesTest.java


示例20: assertNodeOrder

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入依赖的package包/类
/**
 * Asserts the priority order of CFG nodes.
 *
 * Checks that the node type of the highest-priority node matches the
 * first element of the list, the type of the second node matches the
 * second element of the list, and so on.
 *
 * @param cfg The control flow graph.
 * @param nodeTypes The expected node types, in order.
 */
private void assertNodeOrder(ControlFlowGraph<Node> cfg,
    List<Integer> nodeTypes) {
  List<DiGraphNode<Node, Branch>> cfgNodes =
      Lists.newArrayList(cfg.getDirectedGraphNodes());
  Collections.sort(cfgNodes, cfg.getOptionalNodeComparator(true));

  // IMPLICIT RETURN must always be last.
  Node implicitReturn = cfgNodes.remove(cfgNodes.size() - 1).getValue();
  assertNull(implicitReturn == null ? "null" : implicitReturn.toStringTree(),
      implicitReturn);

  assertEquals("Wrong number of CFG nodes",
      nodeTypes.size(), cfgNodes.size());
  for (int i = 0; i < cfgNodes.size(); i++) {
    int expectedType = nodeTypes.get(i);
    int actualType = cfgNodes.get(i).getValue().getType();
    assertEquals(
        "node type mismatch at " + i + ".\n" +
        "found   : " + Token.name(actualType) + "\n" +
        "required: " + Token.name(expectedType) + "\n",
        expectedType, actualType);
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:34,代码来源:ControlFlowAnalysisTest.java



注:本文中的com.google.javascript.jscomp.graph.DiGraph.DiGraphNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextPosition类代码示例发布时间:2022-05-23
下一篇:
Java PagingPredicate类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap