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
6fbcf46a
Commit
6fbcf46a
authored
Jun 23, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: refactor return remover visitor
parent
a36bc8f2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
23 deletions
+21
-23
ConstInlinerVisitor.java
...main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
+1
-1
ReturnVisitor.java
...in/java/jadx/core/dex/visitors/regions/ReturnVisitor.java
+18
-20
FinishTypeInference.java
.../core/dex/visitors/typeinference/FinishTypeInference.java
+1
-1
PostTypeInference.java
...dx/core/dex/visitors/typeinference/PostTypeInference.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/core/dex/visitors/ConstInlinerVisitor.java
View file @
6fbcf46a
...
...
@@ -80,7 +80,7 @@ public class ConstInlinerVisitor extends AbstractVisitor {
}
/**
* This is method similar to PostTypeInference.
visit
method,
* This is method similar to PostTypeInference.
process
method,
* but contains some expensive operations needed only after constant inline
*/
private
static
void
fixTypes
(
MethodNode
mth
,
InsnNode
insn
,
LiteralArg
litArg
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/ReturnVisitor.java
View file @
6fbcf46a
...
...
@@ -12,13 +12,11 @@ import jadx.core.dex.regions.IfRegion;
import
jadx.core.dex.regions.LoopRegion
;
import
jadx.core.dex.regions.SwitchRegion
;
import
jadx.core.dex.visitors.AbstractVisitor
;
import
jadx.core.utils.RegionUtils
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.ListIterator
;
import
java.util.Set
;
/**
* Remove unnecessary return instructions for void methods
...
...
@@ -85,7 +83,7 @@ public class ReturnVisitor extends AbstractVisitor {
IContainer
subBlock
=
itSubBlock
.
previous
();
if
(
subBlock
==
curContainer
)
{
break
;
}
else
if
(
not
Empty
(
subBlock
))
{
}
else
if
(
!
is
Empty
(
subBlock
))
{
return
false
;
}
}
...
...
@@ -95,25 +93,25 @@ public class ReturnVisitor extends AbstractVisitor {
return
true
;
}
private
static
boolean
notEmpty
(
IContainer
subBlock
)
{
if
(
subBlock
.
contains
(
AFlag
.
RETURN
))
{
return
false
;
}
int
insnCount
=
RegionUtils
.
insnsCount
(
subBlock
);
if
(
insnCount
>
1
)
{
return
true
;
}
if
(
insnCount
==
1
)
{
// don't count one 'return' instruction (it will be removed later)
Set
<
BlockNode
>
blocks
=
new
HashSet
<
BlockNode
>();
RegionUtils
.
getAllRegionBlocks
(
subBlock
,
blocks
);
for
(
BlockNode
node
:
blocks
)
{
if
(!
node
.
contains
(
AFlag
.
RETURN
)
&&
!
node
.
getInstructions
().
isEmpty
())
{
return
true
;
/**
* Check if container not contains instructions,
* don't count one 'return' instruction (it will be removed later).
*/
private
static
boolean
isEmpty
(
IContainer
container
)
{
if
(
container
instanceof
BlockNode
)
{
BlockNode
block
=
(
BlockNode
)
container
;
return
block
.
getInstructions
().
isEmpty
()
||
block
.
contains
(
AFlag
.
RETURN
);
}
else
if
(
container
instanceof
IRegion
)
{
IRegion
region
=
(
IRegion
)
container
;
for
(
IContainer
block
:
region
.
getSubBlocks
())
{
if
(!
isEmpty
(
block
))
{
return
false
;
}
}
return
true
;
}
else
{
throw
new
JadxRuntimeException
(
"Unknown container type: "
+
container
.
getClass
());
}
return
false
;
}
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/FinishTypeInference.java
View file @
6fbcf46a
...
...
@@ -19,7 +19,7 @@ public class FinishTypeInference extends AbstractVisitor {
change
=
false
;
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
if
(
PostTypeInference
.
visit
(
mth
,
insn
))
{
if
(
PostTypeInference
.
process
(
mth
,
insn
))
{
change
=
true
;
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/PostTypeInference.java
View file @
6fbcf46a
...
...
@@ -15,7 +15,7 @@ import java.util.List;
public
class
PostTypeInference
{
public
static
boolean
visit
(
MethodNode
mth
,
InsnNode
insn
)
{
public
static
boolean
process
(
MethodNode
mth
,
InsnNode
insn
)
{
switch
(
insn
.
getType
())
{
case
CONST:
RegisterArg
res
=
insn
.
getResult
();
...
...
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