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
6951d0e6
Commit
6951d0e6
authored
Nov 03, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: use NotNull and Nullable annotations
parent
73dd55ea
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
39 deletions
+32
-39
build.gradle
jadx-core/build.gradle
+1
-0
RegisterArg.java
...ain/java/jadx/core/dex/instructions/args/RegisterArg.java
+6
-12
SSAVar.java
...src/main/java/jadx/core/dex/instructions/args/SSAVar.java
+14
-11
TernaryMod.java
.../main/java/jadx/core/dex/visitors/regions/TernaryMod.java
+2
-3
TypeInference.java
...a/jadx/core/dex/visitors/typeinference/TypeInference.java
+9
-13
No files found.
jadx-core/build.gradle
View file @
6951d0e6
...
...
@@ -5,6 +5,7 @@ dependencies {
compile
files
(
'lib/dx-1.8.jar'
)
compile
'org.ow2.asm:asm:5.0.3'
compile
'com.intellij:annotations:12.0'
testCompile
'org.smali:smali:2.0.3'
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/RegisterArg.java
View file @
6951d0e6
...
...
@@ -19,7 +19,8 @@ public class RegisterArg extends InsnArg implements Named {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
RegisterArg
.
class
);
protected
final
int
regNum
;
protected
SSAVar
sVar
;
// not null after SSATransform pass
private
SSAVar
sVar
;
public
RegisterArg
(
int
rn
)
{
this
.
regNum
=
rn
;
...
...
@@ -139,11 +140,7 @@ public class RegisterArg extends InsnArg implements Named {
if
(
sVar
==
null
)
{
return
null
;
}
RegisterArg
assign
=
sVar
.
getAssign
();
if
(
assign
!=
null
)
{
return
assign
.
getParentInsn
();
}
return
null
;
return
sVar
.
getAssign
().
getParentInsn
();
}
public
InsnNode
getPhiAssignInsn
()
{
...
...
@@ -151,12 +148,9 @@ public class RegisterArg extends InsnArg implements Named {
if
(
usePhi
!=
null
)
{
return
usePhi
;
}
RegisterArg
assign
=
sVar
.
getAssign
();
if
(
assign
!=
null
)
{
InsnNode
parent
=
assign
.
getParentInsn
();
if
(
parent
!=
null
&&
parent
.
getType
()
==
InsnType
.
PHI
)
{
return
parent
;
}
InsnNode
parent
=
sVar
.
getAssign
().
getParentInsn
();
if
(
parent
!=
null
&&
parent
.
getType
()
==
InsnType
.
PHI
)
{
return
parent
;
}
return
null
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/instructions/args/SSAVar.java
View file @
6951d0e6
...
...
@@ -5,6 +5,9 @@ import jadx.core.dex.instructions.PhiInsn;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
public
class
SSAVar
{
private
final
int
regNum
;
...
...
@@ -14,21 +17,21 @@ public class SSAVar {
private
int
startUseAddr
;
private
int
endUseAddr
;
@NotNull
private
RegisterArg
assign
;
private
final
List
<
RegisterArg
>
useList
=
new
ArrayList
<
RegisterArg
>(
2
);
@Nullable
private
PhiInsn
usedInPhi
;
private
ArgType
type
;
private
boolean
typeImmutable
;
public
SSAVar
(
int
regNum
,
int
v
,
RegisterArg
assign
)
{
public
SSAVar
(
int
regNum
,
int
v
,
@NotNull
RegisterArg
assign
)
{
this
.
regNum
=
regNum
;
this
.
version
=
v
;
this
.
assign
=
assign
;
if
(
assign
!=
null
)
{
assign
.
setSVar
(
this
);
}
assign
.
setSVar
(
this
);
startUseAddr
=
-
1
;
endUseAddr
=
-
1
;
}
...
...
@@ -51,7 +54,7 @@ public class SSAVar {
int
start
=
Integer
.
MAX_VALUE
;
int
end
=
Integer
.
MIN_VALUE
;
if
(
assign
!=
null
&&
assign
.
getParentInsn
()
!=
null
)
{
if
(
assign
.
getParentInsn
()
!=
null
)
{
int
insnAddr
=
assign
.
getParentInsn
().
getOffset
();
if
(
insnAddr
>=
0
)
{
start
=
Math
.
min
(
insnAddr
,
start
);
...
...
@@ -81,11 +84,12 @@ public class SSAVar {
return
version
;
}
@NotNull
public
RegisterArg
getAssign
()
{
return
assign
;
}
public
void
setAssign
(
RegisterArg
assign
)
{
public
void
setAssign
(
@NotNull
RegisterArg
assign
)
{
this
.
assign
=
assign
;
}
...
...
@@ -114,10 +118,11 @@ public class SSAVar {
}
}
public
void
setUsedInPhi
(
PhiInsn
usedInPhi
)
{
public
void
setUsedInPhi
(
@Nullable
PhiInsn
usedInPhi
)
{
this
.
usedInPhi
=
usedInPhi
;
}
@Nullable
public
PhiInsn
getUsedInPhi
()
{
return
usedInPhi
;
}
...
...
@@ -127,7 +132,7 @@ public class SSAVar {
}
public
int
getVariableUseCount
()
{
if
(
!
isUsedInPhi
()
)
{
if
(
usedInPhi
==
null
)
{
return
useList
.
size
();
}
return
useList
.
size
()
+
usedInPhi
.
getResult
().
getSVar
().
getUseCount
();
...
...
@@ -142,9 +147,7 @@ public class SSAVar {
acceptedType
=
type
;
this
.
type
=
acceptedType
;
}
if
(
assign
!=
null
)
{
assign
.
type
=
acceptedType
;
}
assign
.
type
=
acceptedType
;
for
(
int
i
=
0
,
useListSize
=
useList
.
size
();
i
<
useListSize
;
i
++)
{
useList
.
get
(
i
).
type
=
acceptedType
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/TernaryMod.java
View file @
6951d0e6
...
...
@@ -60,8 +60,8 @@ public class TernaryMod {
}
if
(
t
.
getResult
()
!=
null
&&
e
.
getResult
()
!=
null
)
{
if
(!
t
.
getResult
().
equalRegisterAndType
(
e
.
getResult
())
||
!
t
.
getResult
().
getSVar
().
isUsedInPhi
(
))
{
PhiInsn
phi
=
t
.
getResult
().
getSVar
().
getUsedInPhi
();
if
(
phi
==
null
||
!
t
.
getResult
().
equalRegisterAndType
(
e
.
getResult
()
))
{
return
false
;
}
if
(!
ifRegion
.
getParent
().
replaceSubBlock
(
ifRegion
,
header
))
{
...
...
@@ -71,7 +71,6 @@ public class TernaryMod {
InsnList
.
remove
(
eb
,
e
);
RegisterArg
resArg
;
PhiInsn
phi
=
t
.
getResult
().
getSVar
().
getUsedInPhi
();
if
(
phi
.
getArgsCount
()
==
2
)
{
resArg
=
phi
.
getResult
();
}
else
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInference.java
View file @
6951d0e6
...
...
@@ -28,15 +28,14 @@ public class TypeInference extends AbstractVisitor {
// search variable name
String
name
=
processVarName
(
var
);
if
(
name
!=
null
)
{
var
.
setName
(
name
);
}
var
.
setName
(
name
);
}
// fix type for vars used only in Phi nodes
for
(
SSAVar
sVar
:
mth
.
getSVars
())
{
if
(
sVar
.
isUsedInPhi
())
{
processPhiNode
(
sVar
.
getUsedInPhi
());
PhiInsn
phi
=
sVar
.
getUsedInPhi
();
if
(
phi
!=
null
)
{
processPhiNode
(
phi
);
}
}
}
...
...
@@ -44,10 +43,10 @@ public class TypeInference extends AbstractVisitor {
private
static
ArgType
processType
(
SSAVar
var
)
{
RegisterArg
assign
=
var
.
getAssign
();
List
<
RegisterArg
>
useList
=
var
.
getUseList
();
if
(
assign
!=
null
&&
(
useList
.
isEmpty
()
||
var
.
isTypeImmutable
()
))
{
if
(
useList
.
isEmpty
()
||
var
.
isTypeImmutable
(
))
{
return
assign
.
getType
();
}
ArgType
type
=
assign
!=
null
?
assign
.
getType
()
:
ArgType
.
UNKNOWN
;
ArgType
type
=
assign
.
getType
()
;
for
(
RegisterArg
arg
:
useList
)
{
ArgType
useType
=
arg
.
getType
();
ArgType
newType
=
ArgType
.
merge
(
type
,
useType
);
...
...
@@ -77,19 +76,16 @@ public class TypeInference extends AbstractVisitor {
}
private
static
String
processVarName
(
SSAVar
var
)
{
String
name
=
null
;
if
(
var
.
getAssign
()
!=
null
)
{
name
=
var
.
getAssign
().
getName
();
}
String
name
=
var
.
getAssign
().
getName
();
if
(
name
!=
null
)
{
return
name
;
}
for
(
RegisterArg
arg
:
var
.
getUseList
())
{
String
vName
=
arg
.
getName
();
if
(
vName
!=
null
)
{
name
=
vName
;
return
vName
;
}
}
return
n
ame
;
return
n
ull
;
}
}
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