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
32f94b46
Commit
32f94b46
authored
Feb 07, 2018
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add code lines for while loop
parent
03550649
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
RegionGen.java
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
+4
-2
LoopRegion.java
...src/main/java/jadx/core/dex/regions/loops/LoopRegion.java
+20
-6
No files found.
jadx-core/src/main/java/jadx/core/codegen/RegionGen.java
View file @
32f94b46
...
...
@@ -207,11 +207,13 @@ public class RegionGen extends InsnGen {
if
(
region
.
isConditionAtEnd
())
{
code
.
startLine
(
"do {"
);
makeRegionIndent
(
code
,
region
.
getBody
());
code
.
startLine
(
"} while ("
);
code
.
startLineWithNum
(
region
.
getConditionSourceLine
());
code
.
add
(
"} while ("
);
conditionGen
.
add
(
code
,
condition
);
code
.
add
(
");"
);
}
else
{
code
.
startLine
(
"while ("
);
code
.
startLineWithNum
(
region
.
getConditionSourceLine
());
code
.
add
(
"while ("
);
conditionGen
.
add
(
code
,
condition
);
code
.
add
(
") {"
);
makeRegionIndent
(
code
,
region
.
getBody
());
...
...
jadx-core/src/main/java/jadx/core/dex/regions/loops/LoopRegion.java
View file @
32f94b46
package
jadx
.
core
.
dex
.
regions
.
loops
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
jadx.core.dex.attributes.nodes.LoopInfo
;
import
jadx.core.dex.instructions.IfNode
;
import
jadx.core.dex.instructions.args.RegisterArg
;
...
...
@@ -9,15 +13,15 @@ import jadx.core.dex.nodes.IRegion;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.regions.AbstractRegion
;
import
jadx.core.dex.regions.conditions.IfCondition
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
org.jetbrains.annotations.Nullable
;
public
final
class
LoopRegion
extends
AbstractRegion
{
private
final
LoopInfo
info
;
// loop header contains one 'if' insn, equals null for infinite loop
/**
* loop header contains one 'if' insn, equals null for infinite loop
*/
@Nullable
private
IfCondition
condition
;
private
final
BlockNode
conditionBlock
;
// instruction which must be executed before condition in every loop
...
...
@@ -27,7 +31,7 @@ public final class LoopRegion extends AbstractRegion {
private
LoopType
type
;
public
LoopRegion
(
IRegion
parent
,
LoopInfo
info
,
BlockNode
header
,
boolean
reversed
)
{
public
LoopRegion
(
IRegion
parent
,
LoopInfo
info
,
@Nullable
BlockNode
header
,
boolean
reversed
)
{
super
(
parent
);
this
.
info
=
info
;
this
.
conditionBlock
=
header
;
...
...
@@ -126,6 +130,16 @@ public final class LoopRegion extends AbstractRegion {
}
}
public
int
getConditionSourceLine
()
{
if
(
conditionBlock
!=
null
)
{
List
<
InsnNode
>
condInsns
=
conditionBlock
.
getInstructions
();
if
(!
condInsns
.
isEmpty
())
{
return
condInsns
.
get
(
0
).
getSourceLine
();
}
}
return
0
;
}
public
LoopType
getType
()
{
return
type
;
}
...
...
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