本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}