Commit d2811263 authored by Skylot's avatar Skylot

core: fix processing try/catch in loop

parent 4fb6ada5
...@@ -20,7 +20,7 @@ public final class LoopRegion extends AbstractRegion { ...@@ -20,7 +20,7 @@ public final class LoopRegion extends AbstractRegion {
private final BlockNode conditionBlock; private final BlockNode conditionBlock;
// instruction which must be executed before condition in every loop // instruction which must be executed before condition in every loop
private BlockNode preCondition; private BlockNode preCondition;
private IContainer body; private IRegion body;
private final boolean conditionAtEnd; private final boolean conditionAtEnd;
private LoopType type; private LoopType type;
...@@ -44,11 +44,11 @@ public final class LoopRegion extends AbstractRegion { ...@@ -44,11 +44,11 @@ public final class LoopRegion extends AbstractRegion {
return conditionBlock; return conditionBlock;
} }
public IContainer getBody() { public IRegion getBody() {
return body; return body;
} }
public void setBody(IContainer body) { public void setBody(IRegion body) {
this.body = body; this.body = body;
} }
...@@ -145,6 +145,11 @@ public final class LoopRegion extends AbstractRegion { ...@@ -145,6 +145,11 @@ public final class LoopRegion extends AbstractRegion {
} }
@Override @Override
public boolean replaceSubBlock(IContainer oldBlock, IContainer newBlock) {
return false;
}
@Override
public String baseString() { public String baseString() {
return body.baseString(); return body.baseString();
} }
......
...@@ -7,6 +7,7 @@ import jadx.core.dex.nodes.IRegion; ...@@ -7,6 +7,7 @@ import jadx.core.dex.nodes.IRegion;
import jadx.core.dex.nodes.MethodNode; import jadx.core.dex.nodes.MethodNode;
import jadx.core.dex.regions.AbstractRegion; import jadx.core.dex.regions.AbstractRegion;
import jadx.core.dex.regions.Region; import jadx.core.dex.regions.Region;
import jadx.core.dex.regions.loops.LoopRegion;
import jadx.core.dex.trycatch.CatchAttr; import jadx.core.dex.trycatch.CatchAttr;
import jadx.core.dex.trycatch.ExceptionHandler; import jadx.core.dex.trycatch.ExceptionHandler;
import jadx.core.dex.trycatch.TryCatchBlock; import jadx.core.dex.trycatch.TryCatchBlock;
...@@ -121,7 +122,13 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor { ...@@ -121,7 +122,13 @@ public class ProcessTryCatchRegions extends AbstractRegionVisitor {
/** /**
* Extract all block dominated by 'dominator' to separate region and mark as try/catch block * Extract all block dominated by 'dominator' to separate region and mark as try/catch block
*/ */
private static boolean wrapBlocks(IRegion region, TryCatchBlock tb, BlockNode dominator) { private static boolean wrapBlocks(IRegion replaceRegion, TryCatchBlock tb, BlockNode dominator) {
IRegion region = replaceRegion;
if (region instanceof LoopRegion) {
LoopRegion loop = (LoopRegion) region;
region = loop.getBody();
}
Region newRegion = new Region(region); Region newRegion = new Region(region);
List<IContainer> subBlocks = region.getSubBlocks(); List<IContainer> subBlocks = region.getSubBlocks();
for (IContainer cont : subBlocks) { for (IContainer cont : subBlocks) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment