soot.dava.internal.SET.SETTryNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of soot Show documentation
Show all versions of soot Show documentation
A Java Optimization Framework
package soot.dava.internal.SET;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2003 Jerome Miecznikowski
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import soot.Value;
import soot.dava.DavaBody;
import soot.dava.internal.AST.ASTNode;
import soot.dava.internal.AST.ASTTryNode;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.internal.asg.AugmentedStmtGraph;
import soot.dava.toolkits.base.finders.ExceptionFinder;
import soot.dava.toolkits.base.finders.ExceptionNode;
import soot.jimple.CaughtExceptionRef;
import soot.jimple.GotoStmt;
import soot.jimple.IdentityStmt;
import soot.jimple.Stmt;
import soot.util.IterableSet;
public class SETTryNode extends SETNode {
private ExceptionNode en;
private DavaBody davaBody;
private AugmentedStmtGraph asg;
private final HashMap cb2clone;
public SETTryNode(IterableSet body, ExceptionNode en, AugmentedStmtGraph asg, DavaBody davaBody) {
super(body);
this.en = en;
this.asg = asg;
this.davaBody = davaBody;
add_SubBody(en.get_TryBody());
cb2clone = new HashMap();
Iterator it = en.get_CatchList().iterator();
while (it.hasNext()) {
IterableSet catchBody = (IterableSet) it.next();
IterableSet clone = (IterableSet) catchBody.clone();
cb2clone.put(catchBody, clone);
add_SubBody(clone);
}
getEntryStmt: {
entryStmt = null;
it = body.iterator();
while (it.hasNext()) {
AugmentedStmt as = (AugmentedStmt) it.next();
Iterator pit = as.cpreds.iterator();
while (pit.hasNext()) {
if (body.contains(pit.next()) == false) {
entryStmt = as;
break getEntryStmt;
}
}
}
}
}
public AugmentedStmt get_EntryStmt() {
if (entryStmt != null) {
return entryStmt;
} else {
return (AugmentedStmt) (en.get_TryBody()).getFirst();
}
// return ((SETNode) ((IterableSet) body2childChain.get(
// en.get_TryBody())).getFirst()).get_EntryStmt();
}
public IterableSet get_NaturalExits() {
IterableSet c = new IterableSet();
Iterator it = subBodies.iterator();
while (it.hasNext()) {
Iterator eit = ((SETNode) body2childChain.get(it.next()).getLast()).get_NaturalExits().iterator();
while (eit.hasNext()) {
Object o = eit.next();
if (c.contains(o) == false) {
c.add(o);
}
}
}
return c;
}
public ASTNode emit_AST() {
LinkedList