Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
e46dfc55
Commit
e46dfc55
authored
Dec 12, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: redone return blocks splitting for fix issue #4
parent
e54b7645
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
185 additions
and
83 deletions
+185
-83
BlockMakerVisitor.java
...c/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
+129
-74
FinishRegions.java
...in/java/jadx/core/dex/visitors/regions/FinishRegions.java
+3
-4
RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+4
-3
TypeResolver.java
...ava/jadx/core/dex/visitors/typeresolver/TypeResolver.java
+1
-2
TestCF4.java
jadx-samples/src/main/java/jadx/samples/TestCF4.java
+48
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/BlockMakerVisitor.java
View file @
e46dfc55
This diff is collapsed.
Click to expand it.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/FinishRegions.java
View file @
e46dfc55
package
jadx
.
core
.
dex
.
visitors
.
regions
;
import
jadx.core.dex.instructions.InsnType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.nodes.BlockNode
;
import
jadx.core.dex.nodes.IBlock
;
import
jadx.core.dex.nodes.IRegion
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.LoopRegion
;
import
java.util.Iterator
;
import
java.util.List
;
public
class
FinishRegions
extends
TracedRegionVisitor
{
@Override
...
...
@@ -21,6 +17,8 @@ public class FinishRegions extends TracedRegionVisitor {
BlockNode
block
=
(
BlockNode
)
container
;
// remove last return in void functions
/*
BlockNode block = (BlockNode) container;
if (block.getCleanSuccessors().isEmpty()
&& mth.getReturnType().equals(ArgType.VOID)) {
List<InsnNode> insns = block.getInstructions();
...
...
@@ -33,6 +31,7 @@ public class FinishRegions extends TracedRegionVisitor {
}
}
}
*/
}
private
boolean
blockNotInLoop
(
MethodNode
mth
,
BlockNode
block
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
View file @
e46dfc55
...
...
@@ -4,7 +4,6 @@ import jadx.core.Consts;
import
jadx.core.dex.attributes.AttributeFlag
;
import
jadx.core.dex.attributes.AttributeType
;
import
jadx.core.dex.attributes.AttributesList
;
import
jadx.core.dex.attributes.ForceReturnAttr
;
import
jadx.core.dex.attributes.IAttribute
;
import
jadx.core.dex.attributes.LoopAttr
;
import
jadx.core.dex.instructions.IfNode
;
...
...
@@ -258,6 +257,7 @@ public class RegionMaker {
while
(
next
!=
null
)
{
if
(
isPathExists
(
loopExit
,
next
))
{
// found cross
/*
if (next.getCleanSuccessors().size() == 1) {
BlockNode r = BlockUtils.getNextBlock(next);
if (r != null
...
...
@@ -265,13 +265,14 @@ public class RegionMaker {
&& r.getInstructions().size() > 0
&& r.getInstructions().get(0).getType() == InsnType.RETURN) {
next.getAttributes().add(new ForceReturnAttr(r.getInstructions().get(0)));
}
/*/
else {
} else {
next.getAttributes().add(AttributeFlag.BREAK);
stack.addExit(r);
}
/**/
}
} else {
stack.addExit(next);
}
*/
break
;
}
next
=
BlockUtils
.
getNextBlock
(
next
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeresolver/TypeResolver.java
View file @
e46dfc55
...
...
@@ -67,8 +67,7 @@ public class TypeResolver extends AbstractVisitor {
state
.
assignReg
(
insn
.
getResult
());
}
if
(
block
.
getSuccessors
().
size
()
>
0
)
block
.
setEndState
(
new
BlockRegState
(
state
));
block
.
setEndState
(
new
BlockRegState
(
state
));
}
}
...
...
jadx-samples/src/main/java/jadx/samples/TestCF4.java
0 → 100644
View file @
e46dfc55
package
jadx
.
samples
;
public
class
TestCF4
extends
AbstractTest
{
int
c
;
String
d
;
String
f
;
public
void
testComplexIf
(
String
a
,
int
b
)
{
if
(
d
==
null
||
(
c
==
0
&&
b
!=
-
1
&&
d
.
length
()
==
0
))
{
c
=
a
.
codePointAt
(
c
);
}
else
{
if
(
a
.
length
()
!=
2
)
{
c
=
f
.
compareTo
(
a
);
}
}
}
public
void
checkComplexIf
()
{
d
=
null
;
f
=
null
;
c
=
2
;
testComplexIf
(
"abcdef"
,
0
);
assertEquals
(
c
,
(
int
)
'c'
);
d
=
""
;
f
=
null
;
c
=
0
;
testComplexIf
(
"abcdef"
,
0
);
assertEquals
(
c
,
(
int
)
'a'
);
d
=
""
;
f
=
"1"
;
c
=
777
;
testComplexIf
(
"ab"
,
-
1
);
assertEquals
(
c
,
777
);
}
@Override
public
boolean
testRun
()
throws
Exception
{
checkComplexIf
();
return
true
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
TestCF4
().
testRun
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment