use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class SSATransformer method cleanTagsAndReIndex.
private void cleanTagsAndReIndex(IrMethod method) {
int i = 0;
for (Local local : method.locals) {
local.tag = null;
local._ls_index = i++;
}
}
use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class UnSSATransformer method insertAssignPath.
private void insertAssignPath(IrMethod method, Collection<LabelStmt> phiLabels) {
// FIXME the phi in Exception handler is buggy
List<AssignStmt> buff = new ArrayList<>();
for (LabelStmt labelStmt : phiLabels) {
List<AssignStmt> phis = (List<AssignStmt>) labelStmt.phis;
LiveV[] frame = (LiveV[]) labelStmt.frame;
for (Stmt from : labelStmt._cfg_froms) {
if (from.visited) {
// at lease it is reached by cfg
for (AssignStmt phi : phis) {
Local a = (Local) phi.getOp1();
LiveV v = frame[a._ls_index];
Local local = v.stmt2regMap.get(from);
if (local != a) {
buff.add(Stmts.nAssign(a, local));
}
}
insertAssignPath(method.stmts, from, labelStmt, buff);
buff.clear();
}
}
}
}
use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class ZeroTransformer method transformReportChanged.
@Override
public boolean transformReportChanged(IrMethod method) {
boolean changed = false;
List<AssignStmt> assignStmtList = new ArrayList<>();
for (Stmt p = method.stmts.getFirst(); p != null; p = p.getNext()) {
if (p.st == Stmt.ST.ASSIGN) {
AssignStmt as = (AssignStmt) p;
if (as.getOp1().vt == Value.VT.LOCAL && as.getOp2().vt == Value.VT.CONSTANT) {
Constant cst = (Constant) as.getOp2();
Object value = cst.value;
if (value instanceof Number && !((value instanceof Long) || (value instanceof Double))) {
int v = ((Number) value).intValue();
if (v == 0 || v == 1) {
assignStmtList.add(as);
}
}
}
}
}
if (assignStmtList.size() == 0) {
return false;
}
List<LabelStmt> phiLabels = method.phiLabels;
if (phiLabels != null) {
for (AssignStmt as : assignStmtList) {
Local local = (Local) as.getOp1();
boolean first = true;
for (LabelStmt labelStmt : phiLabels) {
for (AssignStmt phi : labelStmt.phis) {
Value[] vs = phi.getOp2().getOps();
for (int i = 0; i < vs.length; i++) {
Value v = vs[i];
if (v == local) {
if (first) {
first = false;
} else {
Local nLocal = Exprs.nLocal(-1);
method.locals.add(nLocal);
changed = true;
method.stmts.insertBefore(as, Stmts.nAssign(nLocal, as.getOp2().clone()));
vs[i] = nLocal;
}
}
}
}
}
}
}
return changed;
}
use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class AggTransformerTest method t002.
@Test
public void t002() {
Local a = addLocal("a");
Local b = addLocal("b");
Local c = addLocal("c");
addStmt(nAssign(a, nNewIntArray(nInt(5))));
addStmt(nAssign(b, nInt(2)));
addStmt(nAssign(c, nArray(a, b, "I")));
addStmt(nReturn(c));
transform();
Assert.assertTrue(stmts.getSize() == 1);
Assert.assertTrue(locals.size() == 0);
}
use of com.googlecode.dex2jar.ir.expr.Local in project dex2jar by pxb1988.
the class AggTransformerTest method test05.
@Test
public void test05() {
String sbType = "Ljava/lang/StringBuilder;";
String sType = "Ljava/lang/String;";
Local b = addLocal("b");
Local ex = addLocal("ex");
Local c = addLocal("c");
Local d = addLocal("d");
Local e = addLocal("e");
Local cst = addLocal("cst");
addStmt(nAssign(b, nString("123")));
addStmt(nAssign(c, Exprs.nInvokeNew(new Value[0], new String[0], sbType)));
addStmt(nAssign(d, c));
addStmt(nAssign(cst, nString("p1")));
addStmt(nAssign(c, Exprs.nInvokeVirtual(new Value[] { d, cst }, sbType, "append", new String[] { sType }, sbType)));
addStmt(nAssign(e, c));
addStmt(nAssign(cst, nString("p2")));
addStmt(nAssign(c, Exprs.nInvokeVirtual(new Value[] { e, cst }, sbType, "append", new String[] { sType }, sbType)));
addStmt(nAssign(c, Exprs.nInvokeVirtual(new Value[] { c }, sbType, "toString", new String[0], sType)));
addStmt(nReturn(c));
new SSATransformer().transform(method);
transform();
Assert.assertTrue(stmts.getSize() == 1);
Assert.assertTrue(locals.size() == 0);
}
Aggregations