Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package soot.dava.toolkits.base.finders;
/*-
* #%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.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.TreeSet;
import soot.G;
import soot.Singletons;
import soot.Value;
import soot.dava.Dava;
import soot.dava.DavaBody;
import soot.dava.RetriggerAnalysisException;
import soot.dava.internal.SET.SETNode;
import soot.dava.internal.SET.SETSwitchNode;
import soot.dava.internal.asg.AugmentedStmt;
import soot.dava.internal.asg.AugmentedStmtGraph;
import soot.jimple.LookupSwitchStmt;
import soot.jimple.Stmt;
import soot.jimple.TableSwitchStmt;
import soot.util.IterableSet;
public class SwitchFinder implements FactFinder {
public SwitchFinder(Singletons.Global g) {
}
public static SwitchFinder v() {
return G.v().soot_dava_toolkits_base_finders_SwitchFinder();
}
private IterableSet junkBody;
private HashSet targetSet;
private LinkedList targetList, snTargetList, tSuccList;
private HashMap index2target, tSucc2indexSet, tSucc2target, tSucc2Body;
public void find(DavaBody davaBody, AugmentedStmtGraph asg, SETNode SET) throws RetriggerAnalysisException {
Dava.v().log("SwitchFinder::find()");
final String defaultStr = "default";
Iterator asgit = asg.iterator();
while (asgit.hasNext()) {
AugmentedStmt as = (AugmentedStmt) asgit.next();
Stmt s = as.get_Stmt();
if (((s instanceof TableSwitchStmt) == false) && ((s instanceof LookupSwitchStmt) == false)) {
continue;
}
Value key = null;
junkBody = new IterableSet();
targetSet = new HashSet();
targetList = new LinkedList();
snTargetList = new LinkedList();
tSuccList = new LinkedList();
index2target = new HashMap();
tSucc2indexSet = new HashMap();
tSucc2target = new HashMap();
tSucc2Body = new HashMap();
if (s instanceof TableSwitchStmt) {
TableSwitchStmt tss = (TableSwitchStmt) s;
int target_count = tss.getHighIndex() - tss.getLowIndex() + 1;
for (int i = 0; i < target_count; i++) {
build_Bindings(as, new Integer(i + tss.getLowIndex()), asg.get_AugStmt((Stmt) tss.getTarget(i)));
}
build_Bindings(as, defaultStr, asg.get_AugStmt((Stmt) tss.getDefaultTarget()));
key = tss.getKey();
}
else if (s instanceof LookupSwitchStmt) {
LookupSwitchStmt lss = (LookupSwitchStmt) s;
int target_count = lss.getTargetCount();
for (int i = 0; i < target_count; i++) {
build_Bindings(as, new Integer(lss.getLookupValue(i)), asg.get_AugStmt((Stmt) lss.getTarget(i)));
}
build_Bindings(as, defaultStr, asg.get_AugStmt((Stmt) lss.getDefaultTarget()));
key = lss.getKey();
}
Iterator tsit = tSuccList.iterator();
while (tsit.hasNext()) {
AugmentedStmt tSucc = (AugmentedStmt) tsit.next();
AugmentedStmt target = (AugmentedStmt) tSucc2target.get(tSucc);
snTargetList.addLast(
new SwitchNode(target, (TreeSet