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
33c5e082
Commit
33c5e082
authored
Jul 29, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: always check arguments before inline
parent
cbd36aeb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
8 deletions
+53
-8
CodeShrinker.java
...re/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
+5
-8
TestInlineInLoop.java
...est/java/jadx/tests/internal/inline/TestInlineInLoop.java
+48
-0
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/CodeShrinker.java
View file @
33c5e082
...
...
@@ -87,7 +87,8 @@ public class CodeShrinker extends AbstractVisitor {
}
public
WrapInfo
checkInline
(
int
assignPos
,
RegisterArg
arg
)
{
if
(
assignPos
>=
inlineBorder
||
!
canMove
(
assignPos
,
inlineBorder
))
{
if
(!
arg
.
isThis
()
&&
(
assignPos
>=
inlineBorder
||
!
canMove
(
assignPos
,
inlineBorder
)))
{
return
null
;
}
inlineBorder
=
assignPos
;
...
...
@@ -205,13 +206,9 @@ public class CodeShrinker extends AbstractVisitor {
}
int
assignPos
=
insnList
.
getIndex
(
assignInsn
);
if
(
assignPos
!=
-
1
)
{
if
(
assignInsn
.
canReorder
())
{
wrapList
.
add
(
argsInfo
.
inline
(
assignPos
,
arg
));
}
else
{
WrapInfo
wrapInfo
=
argsInfo
.
checkInline
(
assignPos
,
arg
);
if
(
wrapInfo
!=
null
)
{
wrapList
.
add
(
wrapInfo
);
}
WrapInfo
wrapInfo
=
argsInfo
.
checkInline
(
assignPos
,
arg
);
if
(
wrapInfo
!=
null
)
{
wrapList
.
add
(
wrapInfo
);
}
}
else
{
// another block
...
...
jadx-core/src/test/java/jadx/tests/internal/inline/TestInlineInLoop.java
0 → 100644
View file @
33c5e082
package
jadx
.
tests
.
internal
.
inline
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
countString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestInlineInLoop
extends
InternalJadxTest
{
public
static
class
TestCls
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
int
a
=
0
;
int
b
=
4
;
int
c
=
0
;
while
(
a
<
12
)
{
if
(
b
+
a
<
9
&&
b
<
8
)
{
if
(
b
>=
2
&&
a
>
-
1
&&
b
<
6
)
{
System
.
out
.
println
(
"OK"
);
c
=
b
+
1
;
}
c
=
b
;
}
c
=
b
;
b
++;
b
=
c
;
a
++;
}
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
"int c"
));
assertThat
(
code
,
containsOne
(
"c = b + 1"
));
assertThat
(
code
,
countString
(
2
,
"c = b;"
));
assertThat
(
code
,
containsOne
(
"b++;"
));
assertThat
(
code
,
containsOne
(
"b = c"
));
assertThat
(
code
,
containsOne
(
"a++;"
));
}
}
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