Search in sources :

Example 1 with BafBody

use of soot.baf.BafBody in project soot by Sable.

the class PackManager method convertJimpleBodyToBaf.

public BafBody convertJimpleBodyToBaf(SootMethod m) {
    JimpleBody body = (JimpleBody) m.getActiveBody().clone();
    // Change
    // ConditionalBranchFolder.v().transform(body);
    // UnreachableCodeEliminator.v().transform(body);
    // DeadAssignmentEliminator.v().transform(body);
    // UnusedLocalEliminator.v().transform(body);
    BafBody bafBody = Baf.v().newBody(body);
    PackManager.v().getPack("bop").apply(bafBody);
    PackManager.v().getPack("tag").apply(bafBody);
    if (Options.v().validate()) {
        bafBody.validate();
    }
    return bafBody;
}
Also used : BafBody(soot.baf.BafBody) JimpleBody(soot.jimple.JimpleBody)

Example 2 with BafBody

use of soot.baf.BafBody in project soot by Sable.

the class TagAggregator method internalTransform.

protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
    BafBody body = (BafBody) b;
    LinkedList<Tag> tags = new LinkedList<Tag>();
    LinkedList<Unit> units = new LinkedList<Unit>();
    /* aggregate all tags */
    for (Iterator<Unit> unitIt = body.getUnits().iterator(); unitIt.hasNext(); ) {
        final Unit unit = unitIt.next();
        for (Iterator<Tag> tagIt = unit.getTags().iterator(); tagIt.hasNext(); ) {
            final Tag tag = tagIt.next();
            if (wantTag(tag))
                considerTag(tag, unit, tags, units);
        }
    }
    if (units.size() > 0) {
        b.addTag(new CodeAttribute(aggregatedName(), new LinkedList<Unit>(units), new LinkedList<Tag>(tags)));
    }
    fini();
}
Also used : BafBody(soot.baf.BafBody) Unit(soot.Unit) LinkedList(java.util.LinkedList)

Example 3 with BafBody

use of soot.baf.BafBody in project soot by Sable.

the class AbstractASMBackend method getBafBody.

/**
 * Gets the baf body for the given SootMethod. This method will first check
 * whether the method already has a baf body. If not, it will query the local
 * cache. If this fails as well, it will construct a new baf body.
 * @param method The method for which to obtain a baf body
 * @return The baf body for the given method
 */
protected BafBody getBafBody(SootMethod method) {
    final Body activeBody = method.getActiveBody();
    if (activeBody instanceof BafBody)
        return (BafBody) activeBody;
    BafBody body = bafBodyCache.get(method);
    if (body != null)
        return body;
    if (activeBody instanceof JimpleBody) {
        body = PackManager.v().convertJimpleBodyToBaf(method);
    } else {
        throw new RuntimeException("ASM-backend can only translate Baf- and JimpleBodies!");
    }
    bafBodyCache.put(method, body);
    return body;
}
Also used : BafBody(soot.baf.BafBody) JimpleBody(soot.jimple.JimpleBody) BafBody(soot.baf.BafBody) JimpleBody(soot.jimple.JimpleBody)

Aggregations

BafBody (soot.baf.BafBody)3 JimpleBody (soot.jimple.JimpleBody)2 LinkedList (java.util.LinkedList)1 Unit (soot.Unit)1