Fix codegen for arith ops, rename reserved arg names in methods
This commit is contained in:
@@ -571,7 +571,7 @@ public class InsnGen {
|
||||
code.add('(').add(v1).add(' ').add(op.getSymbol()).add(' ').add(v2).add(')');
|
||||
} else {
|
||||
String res = arg(insn.getResult());
|
||||
if (res.equals(v1)) {
|
||||
if (res.equals(v1) && insn.getResult().equals(insn.getArg(0))) {
|
||||
state.add(InsnGenState.NO_RESULT);
|
||||
// "++" or "--"
|
||||
if (insn.getArg(1).isLiteral() && (op == ArithOp.ADD || op == ArithOp.SUB)) {
|
||||
|
||||
@@ -194,7 +194,7 @@ public class MethodGen {
|
||||
String r;
|
||||
int i = 2;
|
||||
do {
|
||||
r = name + i;
|
||||
r = name + "_" + i;
|
||||
i++;
|
||||
} while (varNames.contains(r));
|
||||
varNames.add(r);
|
||||
|
||||
@@ -9,6 +9,7 @@ import jadx.dex.nodes.IRegion;
|
||||
import jadx.dex.nodes.InsnNode;
|
||||
import jadx.dex.nodes.MethodNode;
|
||||
import jadx.dex.trycatch.ExceptionHandler;
|
||||
import jadx.utils.BlockUtils;
|
||||
import jadx.utils.InsnUtils;
|
||||
import jadx.utils.Utils;
|
||||
|
||||
@@ -131,9 +132,11 @@ public class DotGraphVisitor extends AbstractVisitor {
|
||||
for (BlockNode next : block.getDominatesOn())
|
||||
conn.startLine(makeName(block) + " -> " + makeName(next) + "[style=dotted];");
|
||||
|
||||
// // add all dominators connections
|
||||
// for (BlockNode next : BlockUtils.bitsetToBlocks(mth, block.getDoms()))
|
||||
// conn.startLine(makeName(block) + " -> " + makeName(next) + "[style=dotted, color=green];");
|
||||
// add all dominators connections
|
||||
if (false) {
|
||||
for (BlockNode next : BlockUtils.bitsetToBlocks(mth, block.getDoms()))
|
||||
conn.startLine(makeName(block) + " -> " + makeName(next) + "[style=dotted, color=green];");
|
||||
}
|
||||
}
|
||||
|
||||
private String attributesString(IAttributeNode block) {
|
||||
@@ -180,6 +183,7 @@ public class DotGraphVisitor extends AbstractVisitor {
|
||||
.replace("{", "\\{").replace("}", "\\}")
|
||||
.replace("\"", "\\\"")
|
||||
.replace("-", "\\-")
|
||||
.replace("|", "\\|")
|
||||
.replace("\n", NL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package jadx.dex.visitors;
|
||||
|
||||
import jadx.Consts;
|
||||
import jadx.deobf.NameMapper;
|
||||
import jadx.dex.attributes.AttributeType;
|
||||
import jadx.dex.info.MethodInfo;
|
||||
import jadx.dex.instructions.IndexInsnNode;
|
||||
@@ -37,9 +38,10 @@ public class ModVisitor extends AbstractVisitor {
|
||||
return;
|
||||
|
||||
removeStep(mth);
|
||||
|
||||
replaceStep(mth);
|
||||
|
||||
checkArgsNames(mth);
|
||||
|
||||
for (BlockNode block : mth.getBasicBlocks()) {
|
||||
processExceptionHander(mth, block);
|
||||
}
|
||||
@@ -229,4 +231,14 @@ public class ModVisitor extends AbstractVisitor {
|
||||
replaceInsn(block, pos, newInsn);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkArgsNames(MethodNode mth) {
|
||||
for(RegisterArg arg : mth.getArguments(false)) {
|
||||
String name = arg.getTypedVar().getName();
|
||||
if(name != null && NameMapper.isReserved(name)) {
|
||||
name = name + "_" ;
|
||||
arg.getTypedVar().setName(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user