soot.dava.toolkits.base.AST.transformations.UselessLabelFinder 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.toolkits.base.AST.transformations;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 2005 Nomair A. Naeem
* %%
* 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.Iterator;
import java.util.List;
import soot.G;
import soot.Singletons;
import soot.dava.internal.AST.ASTLabeledNode;
import soot.dava.internal.AST.ASTNode;
import soot.dava.internal.AST.ASTStatementSequenceNode;
import soot.dava.internal.AST.ASTTryNode;
import soot.dava.internal.SET.SETNodeLabel;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.internal.javaRep.DAbruptStmt;
import soot.jimple.Stmt;
public class UselessLabelFinder {
public static boolean DEBUG = false;
public UselessLabelFinder(Singletons.Global g) {
}
public static UselessLabelFinder v() {
return G.v().soot_dava_toolkits_base_AST_transformations_UselessLabelFinder();
}
// check whether label on a node is useless
public boolean findAndKill(ASTNode node) {
if (!(node instanceof ASTLabeledNode)) {
if (DEBUG) {
System.out.println("Returning from findAndKill for node of type " + node.getClass());
}
return false;
} else {
if (DEBUG) {
System.out.println("FindAndKill continuing for node fo type" + node.getClass());
}
}
String label = ((ASTLabeledNode) node).get_Label().toString();
if (label == null) {
return false;
}
if (DEBUG) {
System.out.println("dealing with labeled node" + label);
}
List