Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_39073359
jadx
提交
9622c948
J
jadx
项目概览
qq_39073359
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9622c948
编写于
5月 11, 2019
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: use mode flags instead ThreadLocal in type inference
上级
baea5247
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
50 addition
and
27 deletion
+50
-27
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeSearch.java
...java/jadx/core/dex/visitors/typeinference/TypeSearch.java
+3
-0
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java
...java/jadx/core/dex/visitors/typeinference/TypeUpdate.java
+23
-27
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdateFlags.java
...jadx/core/dex/visitors/typeinference/TypeUpdateFlags.java
+15
-0
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdateInfo.java
.../jadx/core/dex/visitors/typeinference/TypeUpdateInfo.java
+9
-0
未找到文件。
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeSearch.java
浏览文件 @
9622c948
...
...
@@ -89,6 +89,9 @@ public class TypeSearch {
applySuccess
=
false
;
}
}
if
(!
applySuccess
)
{
LOG
.
warn
(
"Multi-variable search result apply rejected in {}"
,
mth
);
}
return
applySuccess
;
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java
浏览文件 @
9622c948
...
...
@@ -31,11 +31,12 @@ import static jadx.core.dex.visitors.typeinference.TypeUpdateResult.SAME;
public
final
class
TypeUpdate
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
TypeUpdate
.
class
);
private
static
final
TypeUpdateFlags
FLAGS_EMPTY
=
new
TypeUpdateFlags
();
private
static
final
TypeUpdateFlags
FLAGS_WIDER
=
new
TypeUpdateFlags
().
allowWider
();
private
final
Map
<
InsnType
,
ITypeListener
>
listenerRegistry
;
private
final
TypeCompare
comparator
;
private
ThreadLocal
<
Boolean
>
allowWider
=
new
ThreadLocal
<>();
public
TypeUpdate
(
RootNode
root
)
{
this
.
listenerRegistry
=
initListenerRegistry
();
this
.
comparator
=
new
TypeCompare
(
root
);
...
...
@@ -45,14 +46,22 @@ public final class TypeUpdate {
* Perform recursive type checking and type propagation for all related variables
*/
public
TypeUpdateResult
apply
(
SSAVar
ssaVar
,
ArgType
candidateType
)
{
if
(
candidateType
==
null
)
{
return
REJECT
;
}
if
(!
candidateType
.
isTypeKnown
()
/* && ssaVar.getTypeInfo().getType().isTypeKnown() */
)
{
return
apply
(
ssaVar
,
candidateType
,
FLAGS_EMPTY
);
}
/**
* Allow wider types for apply from debug info and some special cases
*/
public
TypeUpdateResult
applyWithWiderAllow
(
SSAVar
ssaVar
,
ArgType
candidateType
)
{
return
apply
(
ssaVar
,
candidateType
,
FLAGS_WIDER
);
}
private
TypeUpdateResult
apply
(
SSAVar
ssaVar
,
ArgType
candidateType
,
TypeUpdateFlags
flags
)
{
if
(
candidateType
==
null
||
!
candidateType
.
isTypeKnown
())
{
return
REJECT
;
}
TypeUpdateInfo
updateInfo
=
new
TypeUpdateInfo
();
TypeUpdateInfo
updateInfo
=
new
TypeUpdateInfo
(
flags
);
TypeUpdateResult
result
=
updateTypeChecked
(
updateInfo
,
ssaVar
.
getAssign
(),
candidateType
);
if
(
result
==
REJECT
)
{
return
result
;
...
...
@@ -61,7 +70,7 @@ public final class TypeUpdate {
if
(
updates
.
isEmpty
())
{
return
SAME
;
}
if
(
Consts
.
DEBUG
&&
LOG
.
isDebugEnabled
()
)
{
if
(
Consts
.
DEBUG
)
{
LOG
.
debug
(
"Applying types, init for {} -> {}"
,
ssaVar
,
candidateType
);
updates
.
forEach
(
updateEntry
->
LOG
.
debug
(
" {} -> {}"
,
updateEntry
.
getType
(),
updateEntry
.
getArg
()));
}
...
...
@@ -69,18 +78,6 @@ public final class TypeUpdate {
return
CHANGED
;
}
/**
* Allow wider types for apply from debug info and some special cases
*/
public
TypeUpdateResult
applyWithWiderAllow
(
SSAVar
ssaVar
,
ArgType
candidateType
)
{
try
{
allowWider
.
set
(
true
);
return
apply
(
ssaVar
,
candidateType
);
}
finally
{
allowWider
.
set
(
false
);
}
}
private
TypeUpdateResult
updateTypeChecked
(
TypeUpdateInfo
updateInfo
,
InsnArg
arg
,
ArgType
candidateType
)
{
if
(
candidateType
==
null
)
{
throw
new
JadxRuntimeException
(
"Null type update for arg: "
+
arg
);
...
...
@@ -100,13 +97,11 @@ public final class TypeUpdate {
}
return
SAME
;
}
if
(
compareResult
.
isWider
())
{
if
(
allowWider
.
get
()
!=
Boolean
.
TRUE
)
{
if
(
Consts
.
DEBUG
)
{
LOG
.
debug
(
"Type rejected for {}: candidate={} is wider than current={}"
,
arg
,
candidateType
,
currentType
);
}
return
REJECT
;
if
(
compareResult
.
isWider
()
&&
!
updateInfo
.
getFlags
().
isAllowWider
())
{
if
(
Consts
.
DEBUG
)
{
LOG
.
debug
(
"Type rejected for {}: candidate={} is wider than current={}"
,
arg
,
candidateType
,
currentType
);
}
return
REJECT
;
}
if
(
arg
instanceof
RegisterArg
)
{
RegisterArg
reg
=
(
RegisterArg
)
arg
;
...
...
@@ -278,7 +273,8 @@ public final class TypeUpdate {
if
(
changeArg
.
getType
().
isTypeKnown
())
{
// allow result to be wider
TypeCompareEnum
compareTypes
=
comparator
.
compareTypes
(
candidateType
,
changeArg
.
getType
());
boolean
correctType
=
assignChanged
?
compareTypes
.
isWider
()
:
compareTypes
.
isNarrow
();
boolean
correctType
=
compareTypes
==
TypeCompareEnum
.
EQUAL
||
(
assignChanged
?
compareTypes
.
isWider
()
:
compareTypes
.
isNarrow
());
if
(
correctType
&&
inBounds
(
changeArg
,
candidateType
))
{
allowReject
=
true
;
}
else
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdateFlags.java
0 → 100644
浏览文件 @
9622c948
package
jadx.core.dex.visitors.typeinference
;
public
class
TypeUpdateFlags
{
private
boolean
allowWider
;
public
TypeUpdateFlags
allowWider
()
{
this
.
allowWider
=
true
;
return
this
;
}
public
boolean
isAllowWider
()
{
return
allowWider
;
}
}
jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdateInfo.java
浏览文件 @
9622c948
...
...
@@ -7,8 +7,13 @@ import jadx.core.dex.instructions.args.ArgType;
import
jadx.core.dex.instructions.args.InsnArg
;
public
class
TypeUpdateInfo
{
private
final
TypeUpdateFlags
flags
;
private
final
List
<
TypeUpdateEntry
>
updates
=
new
ArrayList
<>();
public
TypeUpdateInfo
(
TypeUpdateFlags
flags
)
{
this
.
flags
=
flags
;
}
public
void
requestUpdate
(
InsnArg
arg
,
ArgType
changeType
)
{
updates
.
add
(
new
TypeUpdateEntry
(
arg
,
changeType
));
}
...
...
@@ -32,4 +37,8 @@ public class TypeUpdateInfo {
public
List
<
TypeUpdateEntry
>
getUpdates
()
{
return
updates
;
}
public
TypeUpdateFlags
getFlags
()
{
return
flags
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录