soot.jbco.bafTransformations.BAFCounter Maven / Gradle / Ivy
package soot.jbco.bafTransformations;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 - 1999 Raja Vallee-Rai
* %%
* 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.Map;
import soot.Body;
import soot.BodyTransformer;
import soot.Unit;
import soot.baf.GotoInst;
import soot.baf.JSRInst;
import soot.baf.TargetArgInst;
import soot.jbco.IJbcoTransform;
public class BAFCounter extends BodyTransformer implements IJbcoTransform {
static int count = 0;
public static String dependancies[] = new String[] { "bb.jbco_counter" };
public String[] getDependencies() {
return dependancies;
}
public static String name = "bb.jbco_counter";
public String getName() {
return name;
}
public void outputSummary() {
out.println("Count: " + count);
}
protected void internalTransform(Body b, String phaseName, Map options) {
for (Unit u : b.getUnits()) {
if (u instanceof TargetArgInst && !(u instanceof GotoInst) && !(u instanceof JSRInst)) {
count++;
}
}
}
}