本文整理汇总了Java中com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge类的典型用法代码示例。如果您正苦于以下问题:Java DiGraphEdge类的具体用法?Java DiGraphEdge怎么用?Java DiGraphEdge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiGraphEdge类属于com.google.javascript.jscomp.graph.DiGraph包,在下文中一共展示了DiGraphEdge类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: enterScope
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
@Override
public void enterScope(NodeTraversal t) {
ControlFlowGraph<Node> cfg = t.getControlFlowGraph();
for (DiGraphEdge<Node, Branch> s : cfg.getImplicitReturn().getInEdges()) {
Node exitNode = s.getSource().getValue();
if (exitNode.getType() != Token.RETURN ||
exitNode.getFirstChild() == null ||
exitNode.getFirstChild().getType() != Token.THIS) {
badFunctionNodes.add(t.getScopeRoot());
return;
}
}
goodFunctionNodes.add(t.getScopeRoot());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:ChainCalls.java
示例2: initialize
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的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
示例3: CheckPathsBetweenNodes
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的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
示例4: checkAllPathsWithoutBackEdges
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的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
示例5: 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
示例6: process
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的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: 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
示例8: flowThrough
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
@Override
LiveVariableLattice flowThrough(Node node, LiveVariableLattice input) {
final BitSet gen = new BitSet(input.liveSet.size());
final BitSet kill = new BitSet(input.liveSet.size());
// Make kills conditional if the node can end abruptly by an exception.
boolean conditional = false;
List<DiGraphEdge<Node, Branch>> edgeList = getCfg().getOutEdges(node);
for (DiGraphEdge<Node, Branch> edge : edgeList) {
if (Branch.ON_EX.equals(edge.getValue())) {
conditional = true;
}
}
computeGenKill(node, gen, kill, conditional);
LiveVariableLattice result = new LiveVariableLattice(input);
// L_in = L_out - Kill + Gen
result.liveSet.andNot(kill);
result.liveSet.or(gen);
return result;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:21,代码来源:LiveVariablesAnalysis.java
示例9: getAllEdges
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
/**
* Gets all the control flow edges from some node with the first token to
* some node with the second token.
*/
private static List<DiGraphEdge<Node, Branch>> getAllEdges(
ControlFlowGraph<Node> cfg, int startToken, int endToken) {
List<DiGraphEdge<Node, Branch>> edges = getAllEdges(cfg);
Iterator<DiGraphEdge<Node, Branch>> it = edges.iterator();
while (it.hasNext()) {
DiGraphEdge<Node, Branch> edge = it.next();
Node startNode = edge.getSource().getValue();
Node endNode = edge.getDestination().getValue();
if (startNode == null || endNode == null ||
startNode.getType() != startToken || endNode.getType() != endToken) {
it.remove();
}
}
return edges;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:ControlFlowAnalysisTest.java
示例10: getAllDownEdges
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
/**
* Gets all the control flow edges of the given type from some node with
* the first token to some node with the second token.
* This edge must flow from a parent to one of its descendants.
*/
private static List<DiGraphEdge<Node, Branch>> getAllDownEdges(
ControlFlowGraph<Node> cfg, int startToken, int endToken, Branch type) {
List<DiGraphEdge<Node, Branch>> edges =
getAllEdges(cfg, startToken, endToken, type);
Iterator<DiGraphEdge<Node, Branch>> it = edges.iterator();
while (it.hasNext()) {
DiGraphEdge<Node, Branch> edge = it.next();
Node source = edge.getSource().getValue();
Node dest = edge.getDestination().getValue();
if (!isAncestor(source, dest)) {
it.remove();
}
}
return edges;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:22,代码来源:ControlFlowAnalysisTest.java
示例11: generateEdgeReport
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
/**
* Generate a description of a specific edge between two nodes.
* For each edge, name the element being linked, the location of the
* reference in the source file, and the type of the reference.
*
* @param builder contents of the report to be generated
* @param referencedDecl name of the declaration being referenced
* @param edge the graph edge being described
*/
private void generateEdgeReport(StringBuilder builder,
Name referencedDecl, DiGraphEdge<Name, Reference> edge) {
String srcDeclName = referencedDecl.getQualifiedName();
builder.append("<li><A HREF=\"#" + srcDeclName + "\">");
builder.append(srcDeclName);
builder.append("</a> ");
Node def = edge.getValue().getSite();
int lineNumber = def.getLineno();
int columnNumber = def.getCharno();
String sourceFile = getSourceFile(def);
generateSourceReferenceLink(builder, sourceFile, lineNumber, columnNumber);
JSType defType = edge.getValue().getSite().getJSType();
generateType(builder, defType);
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:27,代码来源:NameReferenceGraphReport.java
示例12: checkAllPathsWithoutBackEdges
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的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.DiGraphEdge; //导入依赖的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: 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
示例15: process
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的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
示例16: 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
示例17: enterScope
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
@Override
public void enterScope(NodeTraversal t) {
ControlFlowGraph<Node> cfg = t.getControlFlowGraph();
for (DiGraphEdge<Node, Branch> s : cfg.getImplicitReturn().getInEdges()) {
Node exitNode = s.getSource().getValue();
if (!exitNode.isReturn() ||
exitNode.getFirstChild() == null ||
!exitNode.getFirstChild().isThis()) {
badFunctionNodes.add(t.getScopeRoot());
return;
}
}
goodFunctionNodes.add(t.getScopeRoot());
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:ChainCalls.java
示例18: 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
示例19: getInEnv
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
private TypeEnv getInEnv(DiGraphNode<Node, ControlFlowGraph.Branch> dn) {
List<DiGraphEdge<Node, ControlFlowGraph.Branch>> inEdges = dn.getInEdges();
// True for code considered dead in the CFG
if (inEdges.isEmpty()) {
return getEntryTypeEnv();
}
if (inEdges.size() == 1) {
return envs.get(inEdges.get(0));
}
Set<TypeEnv> envSet = new LinkedHashSet<>();
for (DiGraphEdge<Node, ControlFlowGraph.Branch> de : inEdges) {
TypeEnv env = envs.get(de);
if (env != null) {
envSet.add(env);
}
}
if (envSet.isEmpty()) {
return null;
}
return TypeEnv.join(envSet);
}
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:NewTypeInference.java
示例20: getOutEnv
import com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge; //导入依赖的package包/类
private TypeEnv getOutEnv(DiGraphNode<Node, ControlFlowGraph.Branch> dn) {
List<DiGraphEdge<Node, ControlFlowGraph.Branch>> outEdges = dn.getOutEdges();
if (outEdges.isEmpty()) {
// This occurs when visiting a throw in the backward direction.
checkArgument(dn.getValue().isThrow());
return this.typeEnvFromDeclaredTypes;
}
if (outEdges.size() == 1) {
return envs.get(outEdges.get(0));
}
Set<TypeEnv> envSet = new LinkedHashSet<>();
for (DiGraphEdge<Node, ControlFlowGraph.Branch> de : outEdges) {
TypeEnv env = envs.get(de);
if (env != null) {
envSet.add(env);
}
}
checkState(!envSet.isEmpty());
return TypeEnv.join(envSet);
}
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:NewTypeInference.java
注:本文中的com.google.javascript.jscomp.graph.DiGraph.DiGraphEdge类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论