use of soot.dava.internal.AST.ASTTryNode in project soot by Sable.
the class UnreachableCodeEliminator method caseASTTryNode.
// TODO
public void caseASTTryNode(ASTTryNode node) {
// get try body
List<Object> tryBody = node.get_TryBody();
Iterator<Object> it = tryBody.iterator();
// go over the ASTNodes in this tryBody and apply
List<Object> toReturn = new ArrayList<Object>();
while (it.hasNext()) {
ASTNode temp = (ASTNode) it.next();
if (!codeFinder.isConstructReachable(temp)) {
toReturn.add(temp);
} else {
// only apply on reachable nodes
temp.apply(this);
}
}
it = toReturn.iterator();
while (it.hasNext()) {
tryBody.remove(it.next());
}
Map<Object, Object> exceptionMap = node.get_ExceptionMap();
Map<Object, Object> paramMap = node.get_ParamMap();
// get catch list and apply on the following
// a, type of exception caught
// b, local of exception
// c, catchBody
List<Object> catchList = node.get_CatchList();
Iterator<Object> itBody = null;
it = catchList.iterator();
while (it.hasNext()) {
ASTTryNode.container catchBody = (ASTTryNode.container) it.next();
SootClass sootClass = ((SootClass) exceptionMap.get(catchBody));
Type type = sootClass.getType();
// apply on type of exception
caseType(type);
// apply on local of exception
Local local = (Local) paramMap.get(catchBody);
/*
* March 18th, 2006, Since these are always locals we dont have access to ValueBox
*/
decideCaseExprOrRef(local);
// apply on catchBody
List<Object> body = (List<Object>) catchBody.o;
toReturn = new ArrayList<Object>();
itBody = body.iterator();
while (itBody.hasNext()) {
ASTNode temp = (ASTNode) itBody.next();
if (!codeFinder.isConstructReachable(temp)) {
toReturn.add(temp);
} else {
// only apply on reachable nodes
temp.apply(this);
}
}
itBody = toReturn.iterator();
while (itBody.hasNext()) {
body.remove(itBody.next());
}
}
}
Aggregations