本文整理汇总了Java中com.google.javascript.jscomp.DataFlowAnalysis.FlowState类的典型用法代码示例。如果您正苦于以下问题:Java FlowState类的具体用法?Java FlowState怎么用?Java FlowState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FlowState类属于com.google.javascript.jscomp.DataFlowAnalysis包,在下文中一共展示了FlowState类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getFlowStateAtX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private FlowState<LiveVariablesAnalysis.LiveVariableLattice> getFlowStateAtX(
Node node, ControlFlowGraph<Node> cfg) {
if (node.getType() == Token.LABEL) {
if (node.getFirstChild().getString().equals("X")) {
return cfg.getNode(node.getLastChild()).getAnnotation();
}
}
for (Node c = node.getFirstChild(); c != null; c = c.getNext()) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state =
getFlowStateAtX(c, cfg);
if (state != null) {
return state;
}
}
return null;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:LiveVariableAnalysisTest.java
示例2: getFlowStateAtX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private FlowState<LiveVariablesAnalysis.LiveVariableLattice> getFlowStateAtX(
Node node, ControlFlowGraph<Node> cfg) {
if (node.isLabel()) {
if (node.getFirstChild().getString().equals("X")) {
return cfg.getNode(node.getLastChild()).getAnnotation();
}
}
for (Node c = node.getFirstChild(); c != null; c = c.getNext()) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state =
getFlowStateAtX(c, cfg);
if (state != null) {
return state;
}
}
return null;
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:17,代码来源:LiveVariableAnalysisTest.java
示例3: tryRemoveDeadAssignments
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的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
示例4: assertLiveBeforeX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertLiveBeforeX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state =
getFlowStateAtX(src);
assertNotNull(src + " should contain a label 'X:'", state);
assertTrue("Variable" + var + " should be live before X", state.getIn()
.isLive(liveness.getVarIndex(var)));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:LiveVariableAnalysisTest.java
示例5: assertLiveAfterX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertLiveAfterX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state =
getFlowStateAtX(src);
assertTrue("Label X should be in the input program.", state != null);
assertTrue("Variable" + var + " should be live after X", state.getOut()
.isLive(liveness.getVarIndex(var)));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:LiveVariableAnalysisTest.java
示例6: assertNotLiveAfterX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertNotLiveAfterX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state =
getFlowStateAtX(src);
assertTrue("Label X should be in the input program.", state != null);
assertTrue("Variable" + var + " should not be live after X", !state
.getOut().isLive(liveness.getVarIndex(var)));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:LiveVariableAnalysisTest.java
示例7: assertNotLiveBeforeX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertNotLiveBeforeX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state =
getFlowStateAtX(src);
assertTrue("Label X should be in the input program.", state != null);
assertTrue("Variable" + var + " should not be live before X", !state
.getIn().isLive(liveness.getVarIndex(var)));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:LiveVariableAnalysisTest.java
示例8: tryRemoveDeadAssignments
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的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
示例9: assertLiveBeforeX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertLiveBeforeX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state = getFlowStateAtX(src);
assertNotNull(src + " should contain a label 'X:'", state);
assertTrue(
"Variable" + var + " should be live before X",
state.getIn().isLive(liveness.getVarIndex(var)));
}
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:LiveVariablesAnalysisTest.java
示例10: assertLiveAfterX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertLiveAfterX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state = getFlowStateAtX(src);
assertNotNull("Label X should be in the input program.", state);
assertTrue(
"Variable" + var + " should be live after X",
state.getOut().isLive(liveness.getVarIndex(var)));
}
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:LiveVariablesAnalysisTest.java
示例11: assertNotLiveAfterX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertNotLiveAfterX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state = getFlowStateAtX(src);
assertNotNull("Label X should be in the input program.", state);
assertFalse(
"Variable" + var + " should not be live after X",
state.getOut().isLive(liveness.getVarIndex(var)));
}
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:LiveVariablesAnalysisTest.java
示例12: assertNotLiveBeforeX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void assertNotLiveBeforeX(String src, String var) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state = getFlowStateAtX(src);
assertNotNull("Label X should be in the input program.", state);
assertFalse(
"Variable" + var + " should not be live before X",
state.getIn().isLive(liveness.getVarIndex(var)));
}
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:LiveVariablesAnalysisTest.java
示例13: getFlowStateAtX
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private FlowState<LiveVariablesAnalysis.LiveVariableLattice> getFlowStateAtX(
Node node, ControlFlowGraph<Node> cfg) {
if (node.isLabel()) {
if (node.getFirstChild().getString().equals("X")) {
return cfg.getNode(node.getLastChild()).getAnnotation();
}
}
for (Node c = node.getFirstChild(); c != null; c = c.getNext()) {
FlowState<LiveVariablesAnalysis.LiveVariableLattice> state = getFlowStateAtX(c, cfg);
if (state != null) {
return state;
}
}
return null;
}
开发者ID:google,项目名称:closure-compiler,代码行数:16,代码来源:LiveVariablesAnalysisTest.java
示例14: computeVariableNamesInterferenceGraph
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private UndiGraph<Var, Void> computeVariableNamesInterferenceGraph(
NodeTraversal t, ControlFlowGraph<Node> cfg, Set<Var> escaped) {
UndiGraph<Var, Void> interferenceGraph =
new LinkedUndirectedGraph<Var, Void>();
Scope scope = t.getScope();
// First create a node for each non-escaped variable.
for (Iterator<Var> i = scope.getVars(); i.hasNext();) {
Var v = i.next();
if (!escaped.contains(v)) {
// TODO(user): In theory, we CAN coalesce function names just like
// any variables. Our Liveness analysis captures this just like it as
// described in the specification. However, we saw some zipped and
// and unzipped size increase after this. We are not totally sure why
// that is but, for now, we will respect the dead functions and not play
// around with it.
if (!NodeUtil.isFunction(v.getParentNode())) {
interferenceGraph.createNode(v);
}
}
}
// Go through every single point of the program and look at each variable
// pairs. If they are both live at the same time, at an edge between them.
for (DiGraphNode<Node, Branch> cfgNode : cfg.getDirectedGraphNodes()) {
FlowState<LiveVariableLattice> state = cfgNode.getAnnotation();
if (cfg.isImplicitReturn(cfgNode)) {
continue;
}
int varsInScope = scope.getVarCount();
ArrayList<CombinedLiveRangeChecker> rangesToCheck =
new ArrayList<CombinedLiveRangeChecker>(
varsInScope * varsInScope);
for (Iterator<Var> i1 = scope.getVars(); i1.hasNext();) {
Var v1 = i1.next();
for (Iterator<Var> i2 = scope.getVars(); i2.hasNext();) {
Var v2 = i2.next();
if (v1 == v2 || !interferenceGraph.hasNode(v1) ||
!interferenceGraph.hasNode(v2)) {
// Skip nodes that were not added. They are globals and escaped
// locals. Also avoid merging a variable with itself.
continue;
}
boolean v1OutLive = state.getOut().isLive(v1);
boolean v2OutLive = state.getOut().isLive(v2);
// Finally, check the live states and add edge when possible.
if (v1.getParentNode().getType() == Token.LP &&
v2.getParentNode().getType() == Token.LP) {
interferenceGraph.connectIfNotFound(v1, null, v2);
} else if ((state.getIn().isLive(v1) && state.getIn().isLive(v2)) ||
(v1OutLive && v2OutLive)) {
interferenceGraph.connectIfNotFound(v1, null, v2);
} else {
LiveRangeChecker checker1 =
new LiveRangeChecker(v1, v2OutLive ? null : v2);
LiveRangeChecker checker2 =
new LiveRangeChecker(v2, v1OutLive ? null : v1);
rangesToCheck.add(new CombinedLiveRangeChecker(checker1, checker2));
}
}
}
// Do the collected live range checks.
checkRanges(rangesToCheck, cfgNode.getValue());
for (CombinedLiveRangeChecker range : rangesToCheck) {
range.connectIfCrossed(interferenceGraph);
}
}
return interferenceGraph;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:76,代码来源:CoalesceVariableNames.java
示例15: tryRemoveAssignment
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
private void tryRemoveAssignment(NodeTraversal t, Node n,
FlowState<LiveVariableLattice> state) {
tryRemoveAssignment(t, n, n, state);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:5,代码来源:DeadAssignmentsElimination.java
示例16: verifyInHas
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
static void verifyInHas(GraphNode<Instruction, Branch> node, Variable var,
Integer constant) {
FlowState<ConstPropLatticeElement> fState = node.getAnnotation();
assertEquals(constant, fState.getIn().constMap.get(var));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:6,代码来源:DataFlowAnalysisTest.java
示例17: verifyOutHas
import com.google.javascript.jscomp.DataFlowAnalysis.FlowState; //导入依赖的package包/类
static void verifyOutHas(GraphNode<Instruction, Branch> node, Variable var,
Integer constant) {
FlowState<ConstPropLatticeElement> fState = node.getAnnotation();
assertEquals(constant, fState.getOut().constMap.get(var));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:6,代码来源:DataFlowAnalysisTest.java
注:本文中的com.google.javascript.jscomp.DataFlowAnalysis.FlowState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论