use of soot.dava.toolkits.base.AST.structuredAnalysis.CPFlowSet in project soot by Sable.
the class CPApplication method inASTForLoopNode.
public void inASTForLoopNode(ASTForLoopNode node) {
/*
* For the init part we should actually use the before set for each init
* stmt
*/
for (AugmentedStmt as : node.getInit()) {
Stmt s = as.get_Stmt();
List useBoxes = s.getUseBoxes();
Object obj = cp.getBeforeSet(s);
if (obj == null)
continue;
if (!(obj instanceof CPFlowSet))
continue;
// before set is a non null CPFlowSet
CPFlowSet beforeSet = (CPFlowSet) obj;
// System.out.println("Init Statement: "+s);
// System.out.println("Before set is: "+beforeSet.toString());
/*
* get all use boxes see if their value is determined from the
* before set if yes replace them
*/
substituteUses(useBoxes, beforeSet);
}
// get after set for the condition and update
Object obj = cp.getAfterSet(node);
if (obj == null)
return;
if (!(obj instanceof CPFlowSet))
return;
// after set is a non null CPFlowSet
CPFlowSet afterSet = (CPFlowSet) obj;
// conditon
ASTCondition cond = node.get_Condition();
// System.out.println("For Loop with condition: "+cond);
// System.out.println("After set is: "+afterSet.toString());
changedCondition(cond, afterSet);
// update
for (AugmentedStmt as : node.getUpdate()) {
Stmt s = as.get_Stmt();
List useBoxes = s.getUseBoxes();
// System.out.println("For update Statement: "+s);
// System.out.println("After set is: "+afterSet.toString());
/*
* get all use boxes see if their value is determined from the
* before set if yes replace them
*/
substituteUses(useBoxes, afterSet);
}
}
use of soot.dava.toolkits.base.AST.structuredAnalysis.CPFlowSet in project soot by Sable.
the class CPApplication method inASTStatementSequenceNode.
public void inASTStatementSequenceNode(ASTStatementSequenceNode node) {
for (AugmentedStmt as : node.getStatements()) {
Stmt s = as.get_Stmt();
List useBoxes = s.getUseBoxes();
Object obj = cp.getBeforeSet(s);
if (obj == null)
continue;
if (!(obj instanceof CPFlowSet))
continue;
// before set is a non null CPFlowSet
CPFlowSet beforeSet = (CPFlowSet) obj;
// System.out.println("Statement: "+s);
// System.out.println("Before set is: "+beforeSet.toString());
/*
* get all use boxes see if their value is determined from the
* before set if yes replace them
*/
substituteUses(useBoxes, beforeSet);
}
}
use of soot.dava.toolkits.base.AST.structuredAnalysis.CPFlowSet in project soot by Sable.
the class CPApplication method inASTIfNode.
public void inASTIfNode(ASTIfNode node) {
// System.out.println(node);
Object obj = cp.getBeforeSet(node);
if (obj == null)
return;
if (!(obj instanceof CPFlowSet))
return;
// before set is a non null CPFlowSet
CPFlowSet beforeSet = (CPFlowSet) obj;
// System.out.println("Printing before Set for IF"+beforeSet.toString());
ASTCondition cond = node.get_Condition();
// System.out.println("If Statement with condition: "+cond);
// System.out.println("Before set is: "+beforeSet.toString());
changedCondition(cond, beforeSet);
}
use of soot.dava.toolkits.base.AST.structuredAnalysis.CPFlowSet in project soot by Sable.
the class CPApplication method inASTSwitchNode.
public void inASTSwitchNode(ASTSwitchNode node) {
Object obj = cp.getBeforeSet(node);
if (obj == null)
return;
if (!(obj instanceof CPFlowSet))
return;
// before set is a non null CPFlowSet
CPFlowSet beforeSet = (CPFlowSet) obj;
Value key = node.get_Key();
if (key instanceof Local) {
Local useLocal = (Local) key;
// System.out.println("switch key is a local: "+useLocal);
Object value = beforeSet.contains(className, useLocal.toString());
if (value != null) {
// System.out.println("switch key Local "+useLocal+"is present in before set with value"+value);
// create constant value for the value and replace this local
// use with the constant value use
Value newValue = CPHelper.createConstant(value);
if (newValue != null) {
// System.out.println("Substituted the switch key local use with the constant value"+newValue);
node.set_Key(newValue);
} else {
// System.out.println("FAILED TO Substitute the local use with the constant value");
}
}
} else if (key instanceof FieldRef) {
FieldRef useField = (FieldRef) key;
// System.out.println("switch key is a FieldRef which is: "+useField);
SootField usedSootField = useField.getField();
Object value = beforeSet.contains(usedSootField.getDeclaringClass().getName(), usedSootField.getName().toString());
if (value != null) {
// System.out.println("FieldRef "+usedSootField+"is present in before set with value"+value);
// create constant value for the value and replace this local
// use with the constant value use
Value newValue = CPHelper.createConstant(value);
if (newValue != null) {
// System.out.println("Substituted the constant field ref use with the constant value"+newValue);
node.set_Key(newValue);
} else {
// System.out.println("FAILED TO Substitute the constant field ref use with the constant value");
}
}
}
}
use of soot.dava.toolkits.base.AST.structuredAnalysis.CPFlowSet in project soot by Sable.
the class CPApplication method inASTDoWhileNode.
public void inASTDoWhileNode(ASTDoWhileNode node) {
Object obj = cp.getAfterSet(node);
if (obj == null)
return;
if (!(obj instanceof CPFlowSet))
return;
// after set is a non null CPFlowSet
CPFlowSet afterSet = (CPFlowSet) obj;
ASTCondition cond = node.get_Condition();
// System.out.println("Do While Statement with condition: "+cond);
// System.out.println("After set is: "+afterSet.toString());
changedCondition(cond, afterSet);
}
Aggregations