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


Java DiGraphEdge.getValue方法代码示例

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


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

示例1: apply

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
public boolean apply(DiGraphEdge<Node, ControlFlowGraph.Branch> input) {
  // First skill all exceptions.
  Branch branch = input.getValue();
  if (branch == Branch.ON_EX) {
    return false;
  } else if (branch.isConditional()) {
    Node condition = NodeUtil.getConditionExpression(
        input.getSource().getValue());
    // TODO(user): We CAN make this bit smarter just looking at
    // constants. We DO have a full blown ReverseAbstractInterupter and
    // type system that can evaluate some impressions' boolean value but
    // for now we will keep this pass lightweight.
    if (condition != null && NodeUtil.isLiteralValue(condition) ) {
      return NodeUtil.getBooleanValue(condition) ==
        (Branch.ON_TRUE == branch);
    }
  }
  return true;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:CheckMissingReturn.java

示例2: tryEliminateOptionalArgs

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
/**
 * Removes any optional parameters if no callers specifies it as an argument.
 * @param name The name of the function to optimize. 
 * @param edges All the references to this name.
 */
private void tryEliminateOptionalArgs(Name name,
    List<DiGraphEdge<Name, Reference>> edges) {
  
  // Count the maximum number of arguments passed into this function all
  // all points of the program.
  int maxArgs = -1;

  for (DiGraphEdge<Name, Reference> refEdge : edges) {
    Reference ref = refEdge.getValue();
    Node call = ref.parent;

    if (isCallSite(ref)) {
      int numArgs = call.getChildCount() - 1;
      if (numArgs > maxArgs) {
        maxArgs = numArgs;
      }
    } // else this is a definition or a dereference, ignore it.
  }

  for (Definition definition : name.getDeclarations()) {
    eliminateParamsAfter(definition.getRValue(), maxArgs);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:29,代码来源:OptimizeParameters.java

示例3: apply

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
public boolean apply(DiGraphEdge<Node, ControlFlowGraph.Branch> input) {
  // First skill all exceptions.
  Branch branch = input.getValue();
  if (branch == Branch.ON_EX) {
    return false;
  } else if (branch.isConditional()) {
    Node condition = NodeUtil.getConditionExpression(
        input.getSource().getValue());
    // TODO(user): We CAN make this bit smarter just looking at
    // constants. We DO have a full blown ReverseAbstractInterupter and
    // type system that can evaluate some impressions' boolean value but
    // for now we will keep this pass lightweight.
    if (condition != null) {
      TernaryValue val = NodeUtil.getBooleanValue(condition);
      if (val != TernaryValue.UNKNOWN) {
        return val.toBoolean(true) == (Branch.ON_TRUE == branch);
      }
    }
  }
  return true;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:22,代码来源:CheckMissingReturn.java

示例4: tryEliminateOptionalArgs

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
/**
 * Removes any optional parameters if no callers specifies it as an argument.
 * @param name The name of the function to optimize.
 * @param edges All the references to this name.
 */
private void tryEliminateOptionalArgs(Name name,
    List<DiGraphEdge<Name, Reference>> edges) {

  // Count the maximum number of arguments passed into this function all
  // all points of the program.
  int maxArgs = -1;

  for (DiGraphEdge<Name, Reference> refEdge : edges) {
    Reference ref = refEdge.getValue();
    Node call = ref.parent;

    if (isCallSite(ref)) {
      int numArgs = call.getChildCount() - 1;
      if (numArgs > maxArgs) {
        maxArgs = numArgs;
      }
    } // else this is a definition or a dereference, ignore it.
  }

  for (Definition definition : name.getDeclarations()) {
    eliminateParamsAfter(definition.getRValue(), maxArgs);
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:29,代码来源:OptimizeParameters.java

示例5: apply

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
@Override
public boolean apply(DiGraphEdge<Node, ControlFlowGraph.Branch> input) {
  // First skill all exceptions.
  Branch branch = input.getValue();
  if (branch == Branch.ON_EX) {
    return false;
  } else if (branch.isConditional()) {
    Node condition = NodeUtil.getConditionExpression(
        input.getSource().getValue());
    // TODO(user): We CAN make this bit smarter just looking at
    // constants. We DO have a full blown ReverseAbstractInterupter and
    // type system that can evaluate some impressions' boolean value but
    // for now we will keep this pass lightweight.
    if (condition != null) {
      TernaryValue val = NodeUtil.getImpureBooleanValue(condition);
      if (val != TernaryValue.UNKNOWN) {
        return val.toBoolean(true) == (Branch.ON_TRUE == branch);
      }
    }
  }
  return true;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:CheckMissingReturn.java

示例6: analyzeConditionalStmFwd

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
private void analyzeConditionalStmFwd(
    DiGraphNode<Node, ControlFlowGraph.Branch> stm, Node cond, TypeEnv inEnv) {
  for (DiGraphEdge<Node, ControlFlowGraph.Branch> outEdge :
      stm.getOutEdges()) {
    JSType specializedType;
    switch (outEdge.getValue()) {
      case ON_TRUE:
        specializedType = TRUTHY;
        break;
      case ON_FALSE:
        specializedType = FALSY;
        break;
      case ON_EX:
        specializedType = UNKNOWN;
        break;
      default:
        throw new RuntimeException(
            "Condition with an unexpected edge type: " + outEdge.getValue());
    }
    envs.put(outEdge,
        analyzeExprFwd(cond, inEnv, UNKNOWN, specializedType).env);
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:NewTypeInference.java

示例7: branchedFlowThrough

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
@Override
List<ConstPropLatticeElement> branchedFlowThrough(Instruction node,
    ConstPropLatticeElement input) {
  List<ConstPropLatticeElement> result = new ArrayList<>();
  List<DiGraphEdge<Instruction, Branch>> outEdges = getCfg().getOutEdges(node);
  if (node.isArithmetic()) {
    assertThat(outEdges.size()).isLessThan(2);
    ConstPropLatticeElement aResult = flowThroughArithmeticInstruction(
        (ArithmeticInstruction) node, input);
    result.addAll(Collections.nCopies(outEdges.size(), aResult));
  } else {
    BranchInstruction branchInst = (BranchInstruction) node;
    for (DiGraphEdge<Instruction, Branch> branch : outEdges) {
      ConstPropLatticeElement edgeResult = new ConstPropLatticeElement(input);
      if (branch.getValue() == Branch.ON_FALSE &&
          branchInst.getCondition().isVariable()) {
        edgeResult.constMap.put((Variable) branchInst.getCondition(), 0);
      }
      result.add(edgeResult);
    }
  }
  return result;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:DataFlowAnalysisTest.java

示例8: analyzeConditionalStmFwd

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
private void analyzeConditionalStmFwd(Node stm, Node cond, TypeEnv inEnv) {
  for (DiGraphEdge<Node, ControlFlowGraph.Branch> outEdge :
           cfg.getOutEdges(stm)) {
    JSType specializedType;
    switch (outEdge.getValue()) {
      case ON_TRUE:
        specializedType = JSType.TRUTHY;
        break;
      case ON_FALSE:
        specializedType = JSType.FALSY;
        break;
      case ON_EX:
        specializedType = JSType.UNKNOWN;
        break;
      default:
        throw new RuntimeException(
            "Condition with an unexpected edge type: " + outEdge.getValue());
    }
    envs.put(outEdge,
        analyzeExprFwd(cond, inEnv, JSType.UNKNOWN, specializedType).env);
  }
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:23,代码来源:NewTypeInference.java

示例9: branchedFlowThrough

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
@Override
List<ConstPropLatticeElement> branchedFlowThrough(Instruction node,
    ConstPropLatticeElement input) {
  List<ConstPropLatticeElement> result = Lists.newArrayList();
  List<DiGraphEdge<Instruction, Branch>> outEdges = 
    getCfg().getOutEdges(node);
  if (node.isArithmetic()) {
    assertTrue(outEdges.size() < 2);
    ConstPropLatticeElement aResult = flowThroughArithmeticInstruction(
        (ArithmeticInstruction) node, input);
    for (DiGraphEdge<Instruction, Branch> _ : outEdges) {
      result.add(aResult);
    }
  } else {
    BranchInstruction branchInst = (BranchInstruction) node;
    for (DiGraphEdge<Instruction, Branch> branch : outEdges) {
      ConstPropLatticeElement edgeResult =
        new ConstPropLatticeElement(input);
      if (branch.getValue() == Branch.ON_FALSE &&
          branchInst.getCondition().isVariable()) {
        edgeResult.constMap.put((Variable) branchInst.getCondition(), 0);
      }
      result.add(edgeResult);
    }
  }
  return result;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:28,代码来源:DataFlowAnalysisTest.java

示例10: branchedFlowThrough

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
@Override
List<ConstPropLatticeElement> branchedFlowThrough(Instruction node,
    ConstPropLatticeElement input) {
  List<ConstPropLatticeElement> result = Lists.newArrayList();
  List<DiGraphEdge<Instruction, Branch>> outEdges =
    getCfg().getOutEdges(node);
  if (node.isArithmetic()) {
    assertTrue(outEdges.size() < 2);
    ConstPropLatticeElement aResult = flowThroughArithmeticInstruction(
        (ArithmeticInstruction) node, input);
    for (DiGraphEdge<Instruction, Branch> _ : outEdges) {
      result.add(aResult);
    }
  } else {
    BranchInstruction branchInst = (BranchInstruction) node;
    for (DiGraphEdge<Instruction, Branch> branch : outEdges) {
      ConstPropLatticeElement edgeResult =
        new ConstPropLatticeElement(input);
      if (branch.getValue() == Branch.ON_FALSE &&
          branchInst.getCondition().isVariable()) {
        edgeResult.constMap.put((Variable) branchInst.getCondition(), 0);
      }
      result.add(edgeResult);
    }
  }
  return result;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:28,代码来源:DataFlowAnalysisTest.java

示例11: hasExceptionHandler

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
private boolean hasExceptionHandler(Node cfgNode) {
  List<DiGraphEdge<Node, Branch>> branchEdges = getCfg().getOutEdges(cfgNode);
  for (DiGraphEdge<Node, Branch> edge : branchEdges) {
    if (edge.getValue() == Branch.ON_EX) {
      return true;
    }
  }
  return false;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:10,代码来源:MaybeReachingVariableUse.java

示例12: branchedFlowThrough

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
@Override
List<ConstPropLatticeElement> branchedFlowThrough(Instruction node,
    ConstPropLatticeElement input) {
  List<ConstPropLatticeElement> result = Lists.newArrayList();
  List<DiGraphEdge<Instruction, Branch>> outEdges =
    getCfg().getOutEdges(node);
  if (node.isArithmetic()) {
    assertTrue(outEdges.size() < 2);
    ConstPropLatticeElement aResult = flowThroughArithmeticInstruction(
        (ArithmeticInstruction) node, input);
    for (int i = 0; i < outEdges.size(); i++) {
      result.add(aResult);
    }
  } else {
    BranchInstruction branchInst = (BranchInstruction) node;
    for (DiGraphEdge<Instruction, Branch> branch : outEdges) {
      ConstPropLatticeElement edgeResult =
        new ConstPropLatticeElement(input);
      if (branch.getValue() == Branch.ON_FALSE &&
          branchInst.getCondition().isVariable()) {
        edgeResult.constMap.put((Variable) branchInst.getCondition(), 0);
      }
      result.add(edgeResult);
    }
  }
  return result;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:28,代码来源:DataFlowAnalysisTest.java

示例13: traverseNodes

import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入方法依赖的package包/类
private void traverseNodes(Node parent) throws IOException {
  // key
  int keyParent = key(parent);

  // edges
  for (Node child = parent.getFirstChild(); child != null;
      child = child.getNext()) {
    int keyChild = key(child);
    builder.append(INDENT);
    builder.append(formatNodeName(keyParent));
    builder.append(ARROW);
    builder.append(formatNodeName(keyChild));
    builder.append(" [weight=1];\n");

    traverseNodes(child);
  }

  // Flow Edges
  if (cfg != null && cfg.hasNode(parent)) {
    List<DiGraphEdge<Node, Branch>> outEdges =
      cfg.getOutEdges(parent);
    String[] edgeList = new String[outEdges.size()];
    for (int i = 0; i < edgeList.length; i++) {
      DiGraphEdge<Node, ControlFlowGraph.Branch> edge = outEdges.get(i);
      DiGraphNode<Node, Branch> succ = edge.getDestination();

      String toNode = null;
      if (succ == cfg.getImplicitReturn()) {
        toNode = "RETURN";
      } else {
        int keySucc = key(succ.getValue());
        toNode = formatNodeName(keySucc);
      }

      edgeList[i] =
          formatNodeName(keyParent) + ARROW + toNode + " [label=\"" + edge.getValue() + "\", "
          + "fontcolor=\"red\", "
          + "weight=0.01, color=\"red\"];\n";
    }

    Arrays.sort(edgeList);

    for (String element : edgeList) {
      builder.append(INDENT);
      builder.append(element);
    }
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:49,代码来源:DotFormatter.java


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