本文整理了Java中soot.Body.getUnits()
方法的一些代码示例,展示了Body.getUnits()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.getUnits()
方法的具体详情如下:
包路径:soot.Body
类名称:Body
方法名:getUnits
[英]Returns the Chain of Units that make up this body. The units are returned as a PatchingChain. The client can then manipulate the chain, adding and removing units, and the changes will be reflected in the body. Since a PatchingChain is returned the client need not worry about removing exception boundary units or otherwise corrupting the chain.
[中]返回组成此实体的单位链。这些单元作为修补链返回。然后,客户机可以操作链,添加和删除单元,更改将反映在主体中。由于PatchingChain被返回,客户机不必担心删除异常边界单元或以其他方式损坏该链。
代码示例来源:origin: Sable/soot
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
for (Unit u : b.getUnits()) {
if (u instanceof TargetArgInst && !(u instanceof GotoInst) && !(u instanceof JSRInst)) {
count++;
}
}
}
}
代码示例来源:origin: Sable/soot
private Unit getFirstNonIdentityStmt(Body b) {
for (Unit u : b.getUnits()) {
if (!(u instanceof IdentityStmt)) {
return u;
}
}
return null;
}
}
代码示例来源:origin: Sable/soot
private static Unit getFirstNotIdentityStmt(Body body) {
final Iterator<Unit> unitIterator = body.getUnits().snapshotIterator();
while (unitIterator.hasNext()) {
final Unit unit = unitIterator.next();
if (unit instanceof IdentityStmt) {
continue;
}
return unit;
}
logger.debug("There are no non-identity units in the method body.");
return null;
}
代码示例来源:origin: Sable/soot
private IdentityStmt findIdentityStmt(Body b) {
for (Unit u : b.getUnits()) {
Stmt s = (Stmt) u;
if ((s instanceof IdentityStmt) && (((IdentityStmt) s).getRightOp() instanceof ThisRef)) {
return (IdentityStmt) s;
}
}
return null;
}
}
代码示例来源:origin: Sable/soot
protected boolean isThrowInStmtRange(Body b, Stmt begin, Stmt end, Stmt s) {
Iterator it = b.getUnits().iterator(begin, end);
while (it.hasNext()) {
if (it.next().equals(s)) {
return true;
}
}
return false;
}
代码示例来源:origin: Sable/soot
protected Set<Unit> getCallsFromWithinMethod(SootMethod m) {
Set<Unit> res = null;
for (Unit u : m.getActiveBody().getUnits()) {
if (isCallStmt(u)) {
if (res == null) {
res = new LinkedHashSet<Unit>();
}
res.add(u);
}
}
return res == null ? Collections.<Unit>emptySet() : res;
}
代码示例来源:origin: Sable/soot
/** Return unit containing the \@this-assignment **/
public Unit getThisUnit() {
for (Unit u : getUnits()) {
if (u instanceof IdentityStmt && ((IdentityStmt) u).getRightOp() instanceof ThisRef) {
return u;
}
}
throw new RuntimeException("couldn't find this-assignment!" + " in " + getMethod());
}
代码示例来源:origin: Sable/soot
public void initializeUnitToOwner(SootMethod m) {
if (m.hasActiveBody()) {
Body b = m.getActiveBody();
PatchingChain<Unit> units = b.getUnits();
for (Unit unit : units) {
unitToOwner.put(unit, b);
}
}
}
代码示例来源:origin: Sable/soot
@Override
public boolean isFallThroughSuccessor(Unit u, Unit succ) {
assert getSuccsOf(u).contains(succ);
if (!u.fallsThrough()) {
return false;
}
Body body = unitToOwner.get(u);
return body.getUnits().getSuccOf(u) == succ;
}
代码示例来源:origin: Sable/soot
protected void buildNormal() {
Body b = method.retrieveActiveBody();
for (Unit u : b.getUnits()) {
nodeFactory.handleStmt((Stmt) u);
}
}
代码示例来源:origin: Sable/soot
/**
* Add unit to this body.
*
* @param u
* Unit to add.
*/
public void add(Unit u) {
getBody().getUnits().add(u);
}
代码示例来源:origin: Sable/soot
/** Returns a set of units which lie inside the range of any trap. */
public static Set<Unit> getTrappedUnitsOf(Body b) {
Set<Unit> trapsSet = new HashSet<Unit>();
Chain<Unit> units = b.getUnits();
for (Trap t : b.getTraps()) {
Iterator<Unit> it = units.iterator(t.getBeginUnit(), units.getPredOf(t.getEndUnit()));
while (it.hasNext()) {
trapsSet.add(it.next());
}
}
return trapsSet;
}
代码示例来源:origin: Sable/soot
@Override
public void retype(Body body) {
if (realType == null) {
throw new RuntimeException("Real type of this instruction has not been set or was already retyped: " + this);
}
if (body.getUnits().contains(stmtToRetype)) {
Local l = (Local) (stmtToRetype.getLeftOp());
l.setType(realType);
realType = null;
}
}
代码示例来源:origin: Sable/soot
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
Iterator<Unit> it = b.getUnits().snapshotIterator();
while (it.hasNext()) {
Unit u = it.next();
if (u instanceof LookupSwitchStmt) {
LookupSwitchStmt sw = (LookupSwitchStmt) u;
if (sw.getTargetCount() == 0 && sw.getDefaultTarget() != null) {
b.getUnits().swapWith(sw, Jimple.v().newGotoStmt(sw.getDefaultTarget()));
}
}
}
}
}
代码示例来源:origin: Sable/soot
/**
* Create a <code>BlockGraph</code> representing at the basic block level the control flow specified, at the
* <code>Unit</code> level, by a given {@link UnitGraph}.
*
* @param unitGraph
* A representation of the control flow at the level of individual {@link Unit}s.
*/
protected BlockGraph(UnitGraph unitGraph) {
mBody = unitGraph.getBody();
mUnits = mBody.getUnits();
Set<Unit> leaders = computeLeaders(unitGraph);
buildBlocks(leaders, unitGraph);
}
代码示例来源:origin: Sable/soot
@Override
/** Verifies that the UnitBoxes of this Body all point to a Unit contained within this body. */
public void validate(Body body, List<ValidationException> exception) {
for (UnitBox ub : body.getAllUnitBoxes()) {
if (!body.getUnits().contains(ub.getUnit())) {
throw new RuntimeException(
"Unitbox points outside unitChain! to unit : " + ub.getUnit() + " in " + body.getMethod());
}
}
}
代码示例来源:origin: Sable/soot
public void deferredJimplify(DexBody body) {
IfStmt s = ifStatement(body);
body.getBody().getUnits().swapWith(markerUnit, s); // insertAfter(s, markerUnit);
setUnit(s);
}
代码示例来源:origin: Sable/soot
@Override
public Map<Unit, Set<Local>> initialSeeds() {
return DefaultSeeds.make(Collections.singleton(Scene.v().getMainMethod().getActiveBody().getUnits().getFirst()),
zeroValue());
}
}
代码示例来源:origin: Sable/soot
public static soot.Local getPrivateAccessFieldInvoke(soot.SootMethodRef toInvoke, ArrayList params, soot.Body body,
LocalGenerator lg) {
soot.jimple.InvokeExpr invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(toInvoke, params);
soot.Local retLocal = lg.generateLocal(toInvoke.returnType());
soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(retLocal, invoke);
body.getUnits().add(stmt);
return retLocal;
}
代码示例来源:origin: Sable/soot
public void deferredJimplify(DexBody body) {
int keyRegister = ((OneRegisterInstruction) instruction).getRegisterA();
int offset = ((OffsetInstruction) instruction).getCodeOffset();
Local key = body.getRegisterLocal(keyRegister);
int targetAddress = codeAddress + offset;
Instruction targetData = body.instructionAtAddress(targetAddress).instruction;
Stmt stmt = switchStatement(body, targetData, key);
body.getBody().getUnits().insertAfter(stmt, markerUnit);
}
内容来源于网络,如有侵权,请联系作者删除!