use of soot.dava.internal.AST.ASTNode in project soot by Sable.
the class DavaFlowSet method addToImplicitContinues.
public void addToImplicitContinues(DAbruptStmt ab, DavaFlowSet<T> set) {
if (!checkImplicit(ab))
throw new RuntimeException("Tried to add explicit continue statement in the implicit list ");
if (!ab.is_Continue())
throw new RuntimeException("Tried to add break statement in the continue list");
// okkay so its an implicit continue
// get the targetted node, use the ClosestAbruptTargetFinder
ASTNode node = ClosestAbruptTargetFinder.v().getTarget(ab);
// get the list of flow sets already stored for this node
List<DavaFlowSet<T>> listSets = implicitContinues.get(node);
if (listSets == null)
listSets = new ArrayList<DavaFlowSet<T>>();
// if set is not already present in listSets add it and update hashMap
implicitContinues.put(node, addIfNotDuplicate(listSets, set));
}
use of soot.dava.internal.AST.ASTNode in project soot by Sable.
the class DavaFlowSet method addToImplicitBreaks.
/**
* The next two methods take an abruptStmt as input along with a flowSet. It
* should be only invoked for abrupt stmts which do not have explicit labels
*
* The node being targeted by this implicit stmt should be found Then the
* flow set should be added to the list within the appropriate hashmap
*/
public void addToImplicitBreaks(DAbruptStmt ab, DavaFlowSet<T> set) {
if (!checkImplicit(ab))
throw new RuntimeException("Tried to add explicit break statement in the implicit list in");
if (!ab.is_Break())
throw new RuntimeException("Tried to add continue statement in the break list in DavaFlowSet.addToImplicitBreaks");
// okkay so its an implicit break
// get the targetted node, use the ClosestAbruptTargetFinder
ASTNode node = ClosestAbruptTargetFinder.v().getTarget(ab);
// get the list of flow sets already stored for this node
List<DavaFlowSet<T>> listSets = implicitBreaks.get(node);
if (listSets == null)
listSets = new ArrayList<DavaFlowSet<T>>();
// if set is not already present in listSets add it and update hashMap
implicitBreaks.put(node, addIfNotDuplicate(listSets, set));
}
use of soot.dava.internal.AST.ASTNode in project soot by Sable.
the class EliminateConditions method normalRetrieving.
public void normalRetrieving(ASTNode node) {
modified = false;
if (node instanceof ASTSwitchNode) {
do {
modified = false;
dealWithSwitchNode((ASTSwitchNode) node);
} while (modified);
return;
}
// from the Node get the subBodes
Iterator<Object> sbit = node.get_SubBodies().iterator();
while (sbit.hasNext()) {
List subBody = (List) sbit.next();
Iterator it = subBody.iterator();
ASTNode temp = null;
Boolean returned = null;
while (it.hasNext()) {
temp = (ASTNode) it.next();
// only check condition if this is a control flow node
if (temp instanceof ASTControlFlowNode) {
bodyContainingNode = null;
returned = eliminate(temp);
if (returned != null && canChange(returned, temp)) {
break;
} else {
if (DEBUG)
System.out.println("returned is null" + temp.getClass());
bodyContainingNode = null;
}
}
temp.apply(this);
}
// end while going through nodes in subBody
boolean changed = change(returned, temp);
if (changed)
modified = true;
}
if (modified) {
// repeat the whole thing
normalRetrieving(node);
}
}
use of soot.dava.internal.AST.ASTNode in project soot by Sable.
the class SETNode method emit_ASTBody.
public List<Object> emit_ASTBody(IterableSet children) {
LinkedList<Object> l = new LinkedList<Object>();
Iterator cit = children.iterator();
while (cit.hasNext()) {
ASTNode astNode = ((SETNode) cit.next()).emit_AST();
if (astNode != null)
l.addLast(astNode);
}
return l;
}
use of soot.dava.internal.AST.ASTNode in project soot by Sable.
the class UnreachableCodeEliminator method normalRetrieving.
public void normalRetrieving(ASTNode node) {
if (node instanceof ASTSwitchNode) {
dealWithSwitchNode((ASTSwitchNode) node);
return;
}
// from the Node get the subBodes
List<ASTNode> toReturn = new ArrayList<ASTNode>();
Iterator<Object> sbit = node.get_SubBodies().iterator();
while (sbit.hasNext()) {
Object subBody = sbit.next();
Iterator<ASTNode> it = ((List<ASTNode>) subBody).iterator();
// go over the ASTNodes in this subBody and apply
while (it.hasNext()) {
ASTNode temp = it.next();
if (!codeFinder.isConstructReachable(temp)) {
// System.out.println("-------------------------A child of node of type "+node.getClass()+" whose type is "+temp.getClass()+" is unreachable");
toReturn.add(temp);
} else {
// only apply on reachable nodes
temp.apply(this);
}
}
it = toReturn.iterator();
while (it.hasNext()) {
// System.out.println("Removed");
((List) subBody).remove(it.next());
}
}
// end of going over subBodies
}
Aggregations