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

Java GraphReachability类代码示例

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

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



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

示例1: shouldTraverse

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
  GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
  if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {

    // Only report error when there are some line number informations.
    // There are synthetic nodes with no line number informations, nodes
    // introduce by other passes (although not likely since this pass should
    // be executed early) or some rhino bug.
    if (n.getLineno() != -1 &&
        // Allow spurious semi-colons and spurious breaks.
        n.getType() != Token.EMPTY && n.getType() != Token.BREAK) {
      compiler.report(JSError.make(t, n, level, UNREACHABLE_CODE));
      // From now on, we are going to assume the user fixed the error and not
      // give more warning related to code section reachable from this node.
      new GraphReachability<Node, ControlFlowGraph.Branch>(
          t.getControlFlowGraph()).recompute(n);

      // Saves time by not traversing children.
      return false;
    }
  }
  return true;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:CheckUnreachableCode.java


示例2: exitScope

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public void exitScope(NodeTraversal t) {
  Scope scope = t.getScope();

  // Computes the control flow graph.
  ControlFlowAnalysis cfa = new ControlFlowAnalysis(compiler, false, false);
  cfa.process(null, scope.getRootNode());
  ControlFlowGraph<Node> cfg = cfa.getCfg();

  new GraphReachability<Node, ControlFlowGraph.Branch>(cfg)
      .compute(cfg.getEntry().getValue());

  Node root = scope.getRootNode();
  if (scope.isLocal()) {
    root = root.getLastChild();
  }
  NodeTraversal.traverse(
      compiler, root, new EliminationPass(cfg));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:20,代码来源:UnreachableCodeElimination.java


示例3: visit

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的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


示例4: shouldTraverse

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
  GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
  if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {

    // Only report error when there are some line number informations.
    // There are synthetic nodes with no line number informations, nodes
    // introduce by other passes (although not likely since this pass should
    // be executed early) or some rhino bug.
    if (n.getLineno() != -1 &&
        // Allow spurious semi-colons and spurious breaks.
        !n.isEmpty() && !n.isBreak()) {
      compiler.report(t.makeError(n, level, UNREACHABLE_CODE));
      // From now on, we are going to assume the user fixed the error and not
      // give more warning related to code section reachable from this node.
      new GraphReachability<Node, ControlFlowGraph.Branch>(
          t.getControlFlowGraph()).recompute(n);

      // Saves time by not traversing children.
      return false;
    }
  }
  return true;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:CheckUnreachableCode.java


示例5: visit

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  if (parent == null || n.isFunction() || n.isScript()) {
    return;
  }
  DiGraphNode<Node, Branch> gNode = cfg.getDirectedGraphNode(n);
  if (gNode == null) { // Not in CFG.
    return;
  }
  if (gNode.getAnnotation() != GraphReachability.REACHABLE
      || !NodeUtil.mayHaveSideEffects(n, compiler)) {
    removeDeadExprStatementSafely(n);
    return;
  }
  tryRemoveUnconditionalBranching(n);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:17,代码来源:UnreachableCodeElimination.java


示例6: shouldTraverse

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
  GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
  if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {

    // Only report error when there are some line number informations.
    // There are synthetic nodes with no line number informations, nodes
    // introduce by other passes (although not likely since this pass should
    // be executed early) or some rhino bug.
    if (n.getLineno() != -1 &&
        // Allow spurious semi-colons and spurious breaks.
        !n.isEmpty() && !n.isBreak()) {
      compiler.report(t.makeError(n, UNREACHABLE_CODE));
      // From now on, we are going to assume the user fixed the error and not
      // give more warning related to code section reachable from this node.
      new GraphReachability<>(t.getControlFlowGraph()).recompute(n);

      // Saves time by not traversing children.
      return false;
    }
  }
  return true;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:CheckUnreachableCode.java


示例7: visit

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  if (parent == null || 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:nicks,项目名称:closure-compiler-old,代码行数:17,代码来源:UnreachableCodeElimination.java


示例8: shouldTraverse

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
  GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
  if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {

    // Only report error when there are some line number informations.
    // There are synthetic nodes with no line number informations, nodes
    // introduce by other passes (although not likely since this pass should
    // be executed early) or some rhino bug.
    if (n.getLineno() != -1 &&
        // Allow spurious semi-colons and spurious breaks.
        !n.isEmpty() && !n.isBreak()) {
      compiler.report(t.makeError(n, UNREACHABLE_CODE));
      // From now on, we are going to assume the user fixed the error and not
      // give more warning related to code section reachable from this node.
      new GraphReachability<>(
          t.getControlFlowGraph()).recompute(n);

      // Saves time by not traversing children.
      return false;
    }
  }
  return true;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:25,代码来源:CheckUnreachableCode.java


示例9: enterScope

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public void enterScope(NodeTraversal t) {
  Scope scope = t.getScope();

  // Computes the control flow graph.
  ControlFlowAnalysis cfa = new ControlFlowAnalysis(compiler, false);
  cfa.process(null, scope.getRootNode());
  cfgStack.push(curCfg);
  curCfg = cfa.getCfg();

  new GraphReachability<Node, ControlFlowGraph.Branch>(curCfg)
      .compute(curCfg.getEntry().getValue());
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:14,代码来源:UnreachableCodeElimination.java


示例10: visit

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  if (parent == null) {
    return;
  }
  if (n.getType() == Token.FUNCTION || n.getType() == Token.SCRIPT) {
    return;
  }
  // Removes TRYs that had its CATCH removed and/or empty FINALLY.
  if (n.getType() == Token.TRY) {
    Node body = n.getFirstChild();
    Node catchOrFinallyBlock = body.getNext();
    Node finallyBlock = catchOrFinallyBlock.getNext();

    if (!catchOrFinallyBlock.hasChildren() &&
        (finallyBlock == null || !finallyBlock.hasChildren())) {
      n.removeChild(body);
      parent.replaceChild(n, body);
      compiler.reportCodeChange();
      n = body;
    }
  }
  GraphNode<Node, Branch> gNode = curCfg.getNode(n);
  if (gNode == null) { // Not in CFG.
    return;
  }
  if (gNode.getAnnotation() != GraphReachability.REACHABLE ||
      (removeNoOpStatements && !NodeUtil.mayHaveSideEffects(n))) {
    removeDeadExprStatementSafely(n, parent);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:32,代码来源:UnreachableCodeElimination.java


示例11: visit

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
  if (parent == null) {
    return;
  }
  if (n.getType() == Token.FUNCTION || n.getType() == Token.SCRIPT) {
    return;
  }
  // Removes TRYs that had its CATCH removed and/or empty FINALLY.
  // TODO(dcc): Move the parts of this that don't require a control flow
  // graph to PeepholeRemoveDeadCode
  if (n.getType() == Token.TRY) {
    Node body = n.getFirstChild();
    Node catchOrFinallyBlock = body.getNext();
    Node finallyBlock = catchOrFinallyBlock.getNext();

    if (!catchOrFinallyBlock.hasChildren() &&
        (finallyBlock == null || !finallyBlock.hasChildren())) {
      n.removeChild(body);
      parent.replaceChild(n, body);
      compiler.reportCodeChange();
      n = body;
    }
  }
  DiGraphNode<Node, Branch> gNode = curCfg.getDirectedGraphNode(n);
  if (gNode == null) { // Not in CFG.
    return;
  }
  if (gNode.getAnnotation() != GraphReachability.REACHABLE ||
      (removeNoOpStatements && !NodeUtil.mayHaveSideEffects(n))) {
    removeDeadExprStatementSafely(n);
    return;
  }

  tryRemoveUnconditionalBranching(n);
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:37,代码来源:UnreachableCodeElimination.java


示例12: shouldTraverse

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
  if (!shouldCheck(n)) {
    return false;
  }

  if (scopeNeedsInit) {
    initScope(t.getControlFlowGraph());
    scopeNeedsInit = false;
  }

  GraphNode<Node, Branch> gNode = t.getControlFlowGraph().getNode(n);
  if (gNode != null && gNode.getAnnotation() != GraphReachability.REACHABLE) {

    // Only report error when there are some line number informations.
    // There are synthetic nodes with no line number informations, nodes
    // introduce by other passes (although not likely since this pass should
    // be executed early) or some rhino bug.
    if (n.getLineno() != -1 &&
        // Allow spurious semi-colons and spurious breaks.
        n.getType() != Token.EMPTY && n.getType() != Token.BREAK) {
      compiler.report(t.makeError(n, level, UNREACHABLE_CODE));
      // From now on, we are going to assume the user fixed the error and not
      // give more warning related to code section reachable from this node.
      new GraphReachability<Node, ControlFlowGraph.Branch>(
          t.getControlFlowGraph()).recompute(n);

      // Saves time by not traversing children.
      return false;
    }
  }
  return true;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:34,代码来源:CheckUnreachableCode.java


示例13: enterScope

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
@Override
public void enterScope(NodeTraversal t) {
  new GraphReachability<Node, ControlFlowGraph.Branch>(
      t.getControlFlowGraph()).compute(
          t.getControlFlowGraph().getEntry().getValue());
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:7,代码来源:CheckUnreachableCode.java


示例14: testSimple

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
public void testSimple() {
  graph = new LinkedDirectedGraph<String, String>();
  graph.createNode("A");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  
  graph.createNode("B");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertNotReachable("B");
  
  graph.connect("A", "--->", "B");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("B");
  assertNotReachable("A");
  assertReachable("B");
  
  graph.connect("B", "--->", "A");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("B");
  assertReachable("A");
  assertReachable("B");
  
  graph.createNode("C");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertReachable("B");
  assertNotReachable("C");

  graph.createNode("D");
  graph.connect("C", "--->", "D");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertReachable("B");
  assertNotReachable("C");
  assertNotReachable("D");
  reachability.recompute("C");
  assertReachable("C");
  assertReachable("D");
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:45,代码来源:GraphReachabilityTest.java


示例15: assertReachable

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
public void assertReachable(String s) {
  assertSame(s + " should be reachable", graph.getNode(s).getAnnotation(),
      GraphReachability.REACHABLE);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:5,代码来源:GraphReachabilityTest.java


示例16: assertNotReachable

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
public void assertNotReachable(String s) {
  assertNotSame(s + " should not be reachable",
      graph.getNode(s).getAnnotation(), GraphReachability.REACHABLE);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:5,代码来源:GraphReachabilityTest.java


示例17: initScope

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
private void initScope(ControlFlowGraph<Node> controlFlowGraph) {
  new GraphReachability<Node, ControlFlowGraph.Branch>(
      controlFlowGraph, new ReachablePredicate()).compute(
          controlFlowGraph.getEntry().getValue());
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:6,代码来源:CheckUnreachableCode.java


示例18: testSimple

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
public void testSimple() {
  graph = new LinkedDirectedGraph<String, String>();
  graph.createNode("A");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");

  graph.createNode("B");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertNotReachable("B");

  graph.connect("A", "--->", "B");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("B");
  assertNotReachable("A");
  assertReachable("B");

  graph.connect("B", "--->", "A");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("B");
  assertReachable("A");
  assertReachable("B");

  graph.createNode("C");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertReachable("B");
  assertNotReachable("C");

  graph.createNode("D");
  graph.connect("C", "--->", "D");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertReachable("B");
  assertNotReachable("C");
  assertNotReachable("D");
  reachability.recompute("C");
  assertReachable("C");
  assertReachable("D");
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:45,代码来源:GraphReachabilityTest.java


示例19: testSimple

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
public void testSimple() {
  graph = LinkedDirectedGraph.create();
  graph.createNode("A");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");

  graph.createNode("B");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertNotReachable("B");

  graph.connect("A", "--->", "B");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("B");
  assertNotReachable("A");
  assertReachable("B");

  graph.connect("B", "--->", "A");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("B");
  assertReachable("A");
  assertReachable("B");

  graph.createNode("C");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertReachable("B");
  assertNotReachable("C");

  graph.createNode("D");
  graph.connect("C", "--->", "D");
  reachability = new GraphReachability<String, String>(graph);
  reachability.compute("A");
  assertReachable("A");
  assertReachable("B");
  assertNotReachable("C");
  assertNotReachable("D");
  reachability.recompute("C");
  assertReachable("C");
  assertReachable("D");
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:45,代码来源:GraphReachabilityTest.java


示例20: initScope

import com.google.javascript.jscomp.graph.GraphReachability; //导入依赖的package包/类
private void initScope(ControlFlowGraph<Node> controlFlowGraph) {
  new GraphReachability<>(controlFlowGraph, REACHABLE)
      .compute(controlFlowGraph.getEntry().getValue());
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:5,代码来源:CheckUnreachableCode.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java BaseComponent类代码示例发布时间:2022-05-23
下一篇:
Java DefinitionsScopedSearch类代码示例发布时间: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