当前位置: 首页>>代码示例>>Java>>正文


Java DiGraphNode.getValue方法代码示例

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


在下文中一共展示了DiGraphNode.getValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: hasPathWithNoReturn

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
private static boolean hasPathWithNoReturn(ControlFlowGraph<Node> cfg) {
  for (DiGraphNode<Node, ControlFlowGraph.Branch> dn :
           cfg.getDirectedPredNodes(cfg.getImplicitReturn())) {
    Node stm = dn.getValue();
    if (NodeUtil.isLoopStructure(stm)) {
      Node cond = NodeUtil.getConditionExpression(stm);
      if (!(cond != null && NodeUtil.isImpureTrue(cond))) {
        return true;
      }
    } else if (stm.isBreak()) {
      // Allow break after return in switches.
      if (!cfg.getDirectedPredNodes(dn).isEmpty()) {
        return true;
      }
    } else if (!stm.isReturn()) {
      return true;
    }
  }
  return false;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:NewTypeInference.java

示例6: allPathsReturn

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
/**
 * @return true if all paths from block must exit with an explicit return.
 */
private boolean allPathsReturn(Node function) {
  // Computes the control flow graph.
  ControlFlowAnalysis cfa = new ControlFlowAnalysis(
      compiler, false, false);
  cfa.process(null, function);
  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:google,项目名称:closure-compiler,代码行数:21,代码来源:InstrumentFunctions.java

示例7: allPathsReturn

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
/**
 * @return 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:nicks,项目名称:closure-compiler-old,代码行数:21,代码来源:InstrumentFunctions.java

示例8: tryRemoveDeadAssignments

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
/**
 * Try to remove useless assignments from a control flow graph that has been
 * annotated with liveness information.
 *
 * @param t The node traversal.
 * @param cfg The control flow graph of the program annotated with liveness
 *        information.
 */
private void tryRemoveDeadAssignments(NodeTraversal t,
    ControlFlowGraph<Node> cfg) {
  List<DiGraphNode<Node, Branch>> nodes = cfg.getDirectedGraphNodes();

  for (DiGraphNode<Node, Branch> cfgNode : nodes) {
    FlowState<LiveVariableLattice> state =
        cfgNode.getAnnotation();
    Node n = cfgNode.getValue();
    if (n == null) {
      continue;
    }
    switch (n.getType()) {
      case Token.IF:
      case Token.WHILE:
      case Token.DO:
        tryRemoveAssignment(t, NodeUtil.getConditionExpression(n), state);
        continue;
      case Token.FOR:
        if (!NodeUtil.isForIn(n)) {
          tryRemoveAssignment(
              t, NodeUtil.getConditionExpression(n), state);
        }
        continue;
      case Token.SWITCH:
      case Token.CASE:
      case Token.RETURN:
        if (n.hasChildren()) {
          tryRemoveAssignment(t, n.getFirstChild(), state);
        }
        continue;
      // TODO(user): case Token.VAR: Remove var a=1;a=2;.....
    }
    
    tryRemoveAssignment(t, n, state);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:45,代码来源:DeadAssignmentsElimination.java

示例9: computeFixedPoint

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
/**
 * Compute a fixed point for the given graph, entering from the given nodes.
 * @param graph The graph to traverse.
 * @param entrySet The nodes to begin traversing from.
 */
public void computeFixedPoint(DiGraph<N, E> graph, Set<N> entrySet) {
  int cycleCount = 0;
  long nodeCount = graph.getNodes().size();

  // Choose a bail-out heuristically in case the computation
  // doesn't converge.
  long maxIterations = Math.max(nodeCount * nodeCount * nodeCount, 100);

  // Use a LinkedHashSet, so that the traversal is deterministic.
  LinkedHashSet<DiGraphNode<N, E>> workSet =
      Sets.newLinkedHashSet();
  for (N n : entrySet) {
    workSet.add(graph.getDirectedGraphNode(n));
  }
  for (; !workSet.isEmpty() && cycleCount < maxIterations; cycleCount++) {
    // For every out edge in the workSet, traverse that edge. If that
    // edge updates the state of the graph, then add the destination
    // node to the resultSet, so that we can update all of its out edges
    // on the next iteration.
    DiGraphNode<N, E> source = workSet.iterator().next();
    N sourceValue = source.getValue();

    workSet.remove(source);

    List<DiGraphEdge<N, E>> outEdges = source.getOutEdges();
    for (DiGraphEdge<N, E> edge : outEdges) {
      N destNode = edge.getDestination().getValue();
      if (callback.traverseEdge(sourceValue, edge.getValue(), destNode)) {
        workSet.add(edge.getDestination());
      }
    }
  }

  Preconditions.checkState(cycleCount != maxIterations,
      NON_HALTING_ERROR_MSG);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:42,代码来源:FixedPointGraphTraversal.java

示例10: tryRemoveDeadAssignments

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
/**
 * Try to remove useless assignments from a control flow graph that has been
 * annotated with liveness information.
 *
 * @param t The node traversal.
 * @param cfg The control flow graph of the program annotated with liveness
 *        information.
 */
private void tryRemoveDeadAssignments(NodeTraversal t,
    ControlFlowGraph<Node> cfg) {
  Iterable<DiGraphNode<Node, Branch>> nodes = cfg.getDirectedGraphNodes();

  for (DiGraphNode<Node, Branch> cfgNode : nodes) {
    FlowState<LiveVariableLattice> state =
        cfgNode.getAnnotation();
    Node n = cfgNode.getValue();
    if (n == null) {
      continue;
    }
    switch (n.getType()) {
      case Token.IF:
      case Token.WHILE:
      case Token.DO:
        tryRemoveAssignment(t, NodeUtil.getConditionExpression(n), state);
        continue;
      case Token.FOR:
        if (!NodeUtil.isForIn(n)) {
          tryRemoveAssignment(
              t, NodeUtil.getConditionExpression(n), state);
        }
        continue;
      case Token.SWITCH:
      case Token.CASE:
      case Token.RETURN:
        if (n.hasChildren()) {
          tryRemoveAssignment(t, n.getFirstChild(), state);
        }
        continue;
      // TODO(user): case Token.VAR: Remove var a=1;a=2;.....
    }

    tryRemoveAssignment(t, n, state);
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:45,代码来源:DeadAssignmentsElimination.java

示例11: computeFixedPoint

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
/**
 * Compute a fixed point for the given graph, entering from the given nodes.
 * @param graph The graph to traverse.
 * @param entrySet The nodes to begin traversing from.
 */
public void computeFixedPoint(DiGraph<N, E> graph, Set<N> entrySet) {
  int cycleCount = 0;
  long nodeCount = graph.getNodeCount();

  // Choose a bail-out heuristically in case the computation
  // doesn't converge.
  long maxIterations = Math.max(nodeCount * nodeCount * nodeCount, 100);

  // Use a LinkedHashSet, so that the traversal is deterministic.
  LinkedHashSet<DiGraphNode<N, E>> workSet = new LinkedHashSet<>();
  for (N n : entrySet) {
    workSet.add(graph.getDirectedGraphNode(n));
  }
  for (; !workSet.isEmpty() && cycleCount < maxIterations; cycleCount++) {
    // For every out edge in the workSet, traverse that edge. If that
    // edge updates the state of the graph, then add the destination
    // node to the resultSet, so that we can update all of its out edges
    // on the next iteration.
    DiGraphNode<N, E> source = workSet.iterator().next();
    N sourceValue = source.getValue();

    workSet.remove(source);

    List<DiGraphEdge<N, E>> outEdges = source.getOutEdges();
    for (DiGraphEdge<N, E> edge : outEdges) {
      N destNode = edge.getDestination().getValue();
      if (callback.traverseEdge(sourceValue, edge.getValue(), destNode)) {
        workSet.add(edge.getDestination());
      }
    }
  }

  checkState(cycleCount != maxIterations, NON_HALTING_ERROR_MSG);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:40,代码来源:FixedPointGraphTraversal.java

示例12: tryRemoveDeadAssignments

import com.google.javascript.jscomp.graph.DiGraph.DiGraphNode; //导入方法依赖的package包/类
/**
 * Try to remove useless assignments from a control flow graph that has been
 * annotated with liveness information.
 *
 * @param t The node traversal.
 * @param cfg The control flow graph of the program annotated with liveness
 *        information.
 */
private void tryRemoveDeadAssignments(NodeTraversal t,
    ControlFlowGraph<Node> cfg,
    Map<String, Var> allVarsInFn) {
  Iterable<DiGraphNode<Node, Branch>> nodes = cfg.getDirectedGraphNodes();

  for (DiGraphNode<Node, Branch> cfgNode : nodes) {
    FlowState<LiveVariableLattice> state =
        cfgNode.getAnnotation();
    Node n = cfgNode.getValue();
    if (n == null) {
      continue;
    }
    switch (n.getToken()) {
      case IF:
      case WHILE:
      case DO:
        tryRemoveAssignment(t, NodeUtil.getConditionExpression(n), state, allVarsInFn);
        continue;
      case FOR:
      case FOR_IN:
      case FOR_OF:
        if (n.isVanillaFor()) {
          tryRemoveAssignment(t, NodeUtil.getConditionExpression(n), state, allVarsInFn);
        }
        continue;
      case SWITCH:
      case CASE:
      case RETURN:
        if (n.hasChildren()) {
          tryRemoveAssignment(t, n.getFirstChild(), state, allVarsInFn);
        }
        continue;
        // TODO(user): case VAR: Remove var a=1;a=2;.....
      default:
        break;
    }

    tryRemoveAssignment(t, n, state, allVarsInFn);
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:49,代码来源:DeadAssignmentsElimination.java


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