Fix issue for wraped synchronized argument

This commit is contained in:
Skylot
2013-06-15 19:46:01 +04:00
parent cb6ff60671
commit 60615d01c3
3 changed files with 11 additions and 12 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ public class RegionGen extends InsnGen {
}
private void makeSynchronizedRegion(SynchronizedRegion cont, CodeWriter code) throws CodegenException {
code.startLine("synchronized(").add(arg(cont.getArg())).add(") {");
code.startLine("synchronized(").add(arg(cont.getInsn().getArg(0))).add(") {");
makeRegionIndent(code, cont.getRegion());
code.startLine('}');
}
@@ -1,24 +1,24 @@
package jadx.dex.regions;
import jadx.dex.instructions.args.RegisterArg;
import jadx.dex.nodes.IContainer;
import jadx.dex.nodes.IRegion;
import jadx.dex.nodes.InsnNode;
import java.util.List;
public final class SynchronizedRegion extends AbstractRegion {
private final RegisterArg arg;
private final InsnNode insn;
private final Region region;
public SynchronizedRegion(IRegion parent, RegisterArg arg) {
public SynchronizedRegion(IRegion parent, InsnNode insn) {
super(parent);
this.arg = arg;
this.insn = insn;
this.region = new Region(this);
}
public RegisterArg getArg() {
return arg;
public InsnNode getInsn() {
return insn;
}
public Region getRegion() {
@@ -9,7 +9,7 @@ import jadx.dex.attributes.LoopAttr;
import jadx.dex.instructions.IfNode;
import jadx.dex.instructions.InsnType;
import jadx.dex.instructions.SwitchNode;
import jadx.dex.instructions.args.RegisterArg;
import jadx.dex.instructions.args.InsnArg;
import jadx.dex.nodes.BlockNode;
import jadx.dex.nodes.IRegion;
import jadx.dex.nodes.InsnNode;
@@ -269,14 +269,13 @@ public class RegionMaker {
private static final Set<BlockNode> cacheSet = new HashSet<BlockNode>();
private BlockNode processMonitorEnter(IRegion curRegion, BlockNode block, InsnNode insn, RegionStack stack) {
RegisterArg arg = (RegisterArg) insn.getArg(0);
SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, arg);
SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, insn);
synchRegion.getSubBlocks().add(block);
curRegion.getSubBlocks().add(synchRegion);
Set<BlockNode> exits = new HashSet<BlockNode>();
cacheSet.clear();
traverseMonitorExits(arg, block, exits, cacheSet);
traverseMonitorExits(insn.getArg(0), block, exits, cacheSet);
block = BlockUtils.getNextBlock(block);
BlockNode exit;
@@ -298,7 +297,7 @@ public class RegionMaker {
/**
* Traverse from monitor-enter thru successors and collect blocks contains monitor-exit
*/
private void traverseMonitorExits(RegisterArg arg, BlockNode block, Set<BlockNode> exits, Set<BlockNode> visited) {
private void traverseMonitorExits(InsnArg arg, BlockNode block, Set<BlockNode> exits, Set<BlockNode> visited) {
visited.add(block);
for (InsnNode insn : block.getInstructions()) {
if (insn.getType() == InsnType.MONITOR_EXIT