use of soot.UnitBox in project soot by Sable.
the class Walker method outAFullMethodBody.
public void outAFullMethodBody(AFullMethodBody node) {
JimpleBody jBody = Jimple.v().newBody();
if (node.getCatchClause() != null) {
int size = node.getCatchClause().size();
for (int i = 0; i < size; i++) jBody.getTraps().addFirst((Trap) mProductions.removeLast());
}
if (node.getStatement() != null) {
int size = node.getStatement().size();
Unit lastStmt = null;
for (int i = 0; i < size; i++) {
Object o = mProductions.removeLast();
if (o instanceof Unit) {
jBody.getUnits().addFirst((Unit) o);
lastStmt = (Unit) o;
} else if (o instanceof String) {
if (lastStmt == null)
throw new RuntimeException("impossible");
mLabelToStmtMap.put(o, lastStmt);
} else
throw new RuntimeException("impossible");
}
}
if (node.getDeclaration() != null) {
int size = node.getDeclaration().size();
for (int i = 0; i < size; i++) {
List<Local> localList = (List<Local>) mProductions.removeLast();
jBody.getLocals().addAll(localList);
}
}
Iterator<String> it = mLabelToPatchList.keySet().iterator();
while (it.hasNext()) {
String label = it.next();
Unit target = mLabelToStmtMap.get(label);
Iterator patchIt = mLabelToPatchList.get(label).iterator();
while (patchIt.hasNext()) {
UnitBox box = (UnitBox) patchIt.next();
box.setUnit(target);
}
}
/*
* Iterator it = mLabelToStmtMap.keySet().iterator();
* while(it.hasNext()) { String label = (String) it.next(); Unit target
* = (Unit) mLabelToStmtMap.get(label);
*
* List l = (List) mLabelToPatchList.get(label); if(l != null) {
* Iterator patchIt = l.iterator(); while(patchIt.hasNext()) { UnitBox
* box = (UnitBox) patchIt.next(); box.setUnit(target); } } }
*/
mProductions.addLast(jBody);
}
use of soot.UnitBox in project soot by Sable.
the class Walker method outATableswitchStatement.
public void outATableswitchStatement(ATableswitchStatement node) {
List<UnitBox> targets = new ArrayList<UnitBox>();
UnitBox defaultTarget = null;
int lowIndex = 0, highIndex = 0;
if (node.getCaseStmt() != null) {
int size = node.getCaseStmt().size();
for (int i = 0; i < size; i++) {
Object valueTargetPair = mProductions.removeLast();
if (valueTargetPair instanceof UnitBox) {
if (defaultTarget != null)
throw new RuntimeException("error: can't ;have more than 1 default stmt");
defaultTarget = (UnitBox) valueTargetPair;
} else {
Object[] pair = (Object[]) valueTargetPair;
if ((i == 0 && defaultTarget == null) || (i == 1 && defaultTarget != null))
highIndex = ((IntConstant) pair[0]).value;
if (i == (size - 1))
lowIndex = ((IntConstant) pair[0]).value;
targets.add(0, (UnitBox) pair[1]);
}
}
} else {
throw new RuntimeException("error: switch stmt has no case stmts");
}
Value key = (Value) mProductions.removeLast();
Unit switchStmt = Jimple.v().newTableSwitchStmt(key, lowIndex, highIndex, targets, defaultTarget);
mProductions.addLast(switchStmt);
}
use of soot.UnitBox in project soot by Sable.
the class Walker method outAIfStatement.
public void outAIfStatement(AIfStatement node) {
String targetLabel = (String) mProductions.removeLast();
Value condition = (Value) mProductions.removeLast();
UnitBox box = Jimple.v().newStmtBox(null);
Unit u = Jimple.v().newIfStmt(condition, box);
addBoxToPatch(targetLabel, box);
mProductions.addLast(u);
}
Aggregations