use of soot.Unit in project soot by Sable.
the class Util method findLastIdentityUnit.
/**
* A new "normal" statement cannot be inserted in the middle of special
* "identity statements" (a = @parameter or b = @this in Jimple).
*
* This method returns the last "identity statement" of the method.
* @param b
* @param s
* @return
*/
public static Unit findLastIdentityUnit(Body b, Stmt s) {
Unit u2 = s;
Unit u1 = s;
while (u1 instanceof IdentityStmt) {
u2 = u1;
u1 = b.getUnits().getSuccOf(u1);
}
return u2;
}
use of soot.Unit in project soot by Sable.
the class SparkTransformer method addTags.
protected void addTags(PAG pag) {
final Tag unknown = new StringTag("Untagged Spark node");
final Map<Node, Tag> nodeToTag = pag.getNodeTags();
for (final SootClass c : Scene.v().getClasses()) {
for (final SootMethod m : c.getMethods()) {
if (!m.isConcrete())
continue;
if (!m.hasActiveBody())
continue;
for (final Unit u : m.getActiveBody().getUnits()) {
final Stmt s = (Stmt) u;
if (s instanceof DefinitionStmt) {
Value lhs = ((DefinitionStmt) s).getLeftOp();
VarNode v = null;
if (lhs instanceof Local) {
v = pag.findLocalVarNode(lhs);
} else if (lhs instanceof FieldRef) {
v = pag.findGlobalVarNode(((FieldRef) lhs).getField());
}
if (v != null) {
PointsToSetInternal p2set = v.getP2Set();
p2set.forall(new P2SetVisitor() {
public final void visit(Node n) {
addTag(s, n, nodeToTag, unknown);
}
});
Node[] simpleSources = pag.simpleInvLookup(v);
for (Node element : simpleSources) {
addTag(s, element, nodeToTag, unknown);
}
simpleSources = pag.allocInvLookup(v);
for (Node element : simpleSources) {
addTag(s, element, nodeToTag, unknown);
}
simpleSources = pag.loadInvLookup(v);
for (Node element : simpleSources) {
addTag(s, element, nodeToTag, unknown);
}
}
}
}
}
}
}
use of soot.Unit in project soot by Sable.
the class JTableSwitchStmt method toString.
public String toString() {
StringBuffer buffer = new StringBuffer();
String endOfLine = " ";
buffer.append(Jimple.TABLESWITCH + "(" + keyBox.getValue().toString() + ")" + endOfLine);
buffer.append("{" + endOfLine);
// The case for "i == highIndex" is handled separately after the loop.
for (int i = lowIndex; i < highIndex; i++) {
Unit target = getTarget(i - lowIndex);
buffer.append(" " + Jimple.CASE + " " + i + ": " + Jimple.GOTO + " " + (target == this ? "self" : target) + ";" + endOfLine);
}
Unit target = getTarget(highIndex - lowIndex);
buffer.append(" " + Jimple.CASE + " " + highIndex + ": " + Jimple.GOTO + " " + (target == this ? "self" : target) + ";" + endOfLine);
target = getDefaultTarget();
buffer.append(" " + Jimple.DEFAULT + ": " + Jimple.GOTO + " " + (target == this ? "self" : target) + ";" + endOfLine);
buffer.append("}");
return buffer.toString();
}
use of soot.Unit in project soot by Sable.
the class JTableSwitchStmt method convertToBaf.
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
List<PlaceholderInst> targetPlaceholders = new ArrayList<PlaceholderInst>();
((ConvertToBaf) getKey()).convertToBaf(context, out);
for (Unit target : getTargets()) {
targetPlaceholders.add(Baf.v().newPlaceholderInst(target));
}
Unit u = Baf.v().newTableSwitchInst(Baf.v().newPlaceholderInst(getDefaultTarget()), lowIndex, highIndex, targetPlaceholders);
u.addAllTagsOf(this);
out.add(u);
}
use of soot.Unit in project soot by Sable.
the class JDynamicInvokeExpr method convertToBaf.
public void convertToBaf(JimpleToBafContext context, List<Unit> out) {
if (argBoxes != null) {
for (ValueBox element : argBoxes) {
((ConvertToBaf) (element.getValue())).convertToBaf(context, out);
}
}
List<Value> bsmArgs = new ArrayList<Value>();
for (ValueBox argBox : bsmArgBoxes) {
bsmArgs.add(argBox.getValue());
}
Unit u = Baf.v().newDynamicInvokeInst(bsmRef, bsmArgs, methodRef, tag);
u.addAllTagsOf(context.getCurrentUnit());
out.add(u);
}
Aggregations