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
71f24911
Commit
71f24911
authored
Jun 26, 2015
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: allow to skip sub-blocks for region visitor.
parent
1d84c001
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
13 deletions
+23
-13
AbstractRegionVisitor.java
...jadx/core/dex/visitors/regions/AbstractRegionVisitor.java
+2
-1
CheckRegions.java
...ain/java/jadx/core/dex/visitors/regions/CheckRegions.java
+2
-1
CleanRegions.java
...ain/java/jadx/core/dex/visitors/regions/CleanRegions.java
+3
-2
DepthRegionTraversal.java
.../jadx/core/dex/visitors/regions/DepthRegionTraversal.java
+4
-3
IRegionVisitor.java
...n/java/jadx/core/dex/visitors/regions/IRegionVisitor.java
+4
-1
IfRegionVisitor.java
.../java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
+2
-1
LoopRegionVisitor.java
...ava/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
+2
-1
TracedRegionVisitor.java
...a/jadx/core/dex/visitors/regions/TracedRegionVisitor.java
+4
-3
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/regions/AbstractRegionVisitor.java
View file @
71f24911
...
...
@@ -7,7 +7,8 @@ import jadx.core.dex.nodes.MethodNode;
public
abstract
class
AbstractRegionVisitor
implements
IRegionVisitor
{
@Override
public
void
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
public
boolean
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
return
true
;
}
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/CheckRegions.java
View file @
71f24911
...
...
@@ -64,13 +64,14 @@ public class CheckRegions extends AbstractVisitor {
// check loop conditions
DepthRegionTraversal
.
traverse
(
mth
,
new
AbstractRegionVisitor
()
{
@Override
public
void
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
public
boolean
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
if
(
region
instanceof
LoopRegion
)
{
BlockNode
loopHeader
=
((
LoopRegion
)
region
).
getHeader
();
if
(
loopHeader
!=
null
&&
loopHeader
.
getInstructions
().
size
()
!=
1
)
{
ErrorsCounter
.
methodError
(
mth
,
"Incorrect condition in loop: "
+
loopHeader
);
}
}
return
true
;
}
});
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/CleanRegions.java
View file @
71f24911
...
...
@@ -23,9 +23,9 @@ public class CleanRegions {
}
IRegionVisitor
removeEmptyBlocks
=
new
AbstractRegionVisitor
()
{
@Override
public
void
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
public
boolean
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
if
(!(
region
instanceof
Region
))
{
return
;
return
true
;
}
for
(
Iterator
<
IContainer
>
it
=
region
.
getSubBlocks
().
iterator
();
it
.
hasNext
();
)
{
...
...
@@ -42,6 +42,7 @@ public class CleanRegions {
}
}
return
true
;
}
};
DepthRegionTraversal
.
traverse
(
mth
,
removeEmptyBlocks
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/DepthRegionTraversal.java
View file @
71f24911
...
...
@@ -53,9 +53,10 @@ public class DepthRegionTraversal {
visitor
.
processBlock
(
mth
,
(
IBlock
)
container
);
}
else
if
(
container
instanceof
IRegion
)
{
IRegion
region
=
(
IRegion
)
container
;
visitor
.
enterRegion
(
mth
,
region
);
for
(
IContainer
subCont
:
region
.
getSubBlocks
())
{
traverseInternal
(
mth
,
visitor
,
subCont
);
if
(
visitor
.
enterRegion
(
mth
,
region
))
{
for
(
IContainer
subCont
:
region
.
getSubBlocks
())
{
traverseInternal
(
mth
,
visitor
,
subCont
);
}
}
visitor
.
leaveRegion
(
mth
,
region
);
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IRegionVisitor.java
View file @
71f24911
...
...
@@ -8,7 +8,10 @@ public interface IRegionVisitor {
void
processBlock
(
MethodNode
mth
,
IBlock
container
);
void
enterRegion
(
MethodNode
mth
,
IRegion
region
);
/**
* @return true for traverse sub-blocks, false otherwise.
*/
boolean
enterRegion
(
MethodNode
mth
,
IRegion
region
);
void
leaveRegion
(
MethodNode
mth
,
IRegion
region
);
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfRegionVisitor.java
View file @
71f24911
...
...
@@ -38,10 +38,11 @@ public class IfRegionVisitor extends AbstractVisitor implements IRegionVisitor,
}
@Override
public
void
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
public
boolean
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
if
(
region
instanceof
IfRegion
)
{
processIfRegion
(
mth
,
(
IfRegion
)
region
);
}
return
true
;
}
@Override
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java
View file @
71f24911
...
...
@@ -47,10 +47,11 @@ public class LoopRegionVisitor extends AbstractVisitor implements IRegionVisitor
}
@Override
public
void
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
public
boolean
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
if
(
region
instanceof
LoopRegion
)
{
processLoopRegion
(
mth
,
(
LoopRegion
)
region
);
}
return
true
;
}
private
static
void
processLoopRegion
(
MethodNode
mth
,
LoopRegion
loopRegion
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/TracedRegionVisitor.java
View file @
71f24911
...
...
@@ -12,12 +12,13 @@ public abstract class TracedRegionVisitor implements IRegionVisitor {
protected
final
Deque
<
IRegion
>
regionStack
=
new
ArrayDeque
<
IRegion
>();
@Override
public
final
void
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
public
boolean
enterRegion
(
MethodNode
mth
,
IRegion
region
)
{
regionStack
.
push
(
region
);
return
true
;
}
@Override
public
final
void
processBlock
(
MethodNode
mth
,
IBlock
container
)
{
public
void
processBlock
(
MethodNode
mth
,
IBlock
container
)
{
IRegion
curRegion
=
regionStack
.
peek
();
processBlockTraced
(
mth
,
container
,
curRegion
);
}
...
...
@@ -25,7 +26,7 @@ public abstract class TracedRegionVisitor implements IRegionVisitor {
public
abstract
void
processBlockTraced
(
MethodNode
mth
,
IBlock
container
,
IRegion
currentRegion
);
@Override
public
final
void
leaveRegion
(
MethodNode
mth
,
IRegion
region
)
{
public
void
leaveRegion
(
MethodNode
mth
,
IRegion
region
)
{
regionStack
.
pop
();
}
}
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