Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ql04210214
jadx
提交
56eac437
J
jadx
项目概览
ql04210214
/
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,体验更适合开发者的 AI 搜索 >>
提交
56eac437
编写于
5月 02, 2013
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix errors in AttributesList, refactoring
上级
b4d08bdc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
18 deletion
+62
-18
src/main/java/jadx/dex/attributes/AttributeType.java
src/main/java/jadx/dex/attributes/AttributeType.java
+18
-3
src/main/java/jadx/dex/attributes/AttributesList.java
src/main/java/jadx/dex/attributes/AttributesList.java
+44
-15
未找到文件。
src/main/java/jadx/dex/attributes/AttributeType.java
浏览文件 @
56eac437
...
@@ -8,12 +8,10 @@ public enum AttributeType {
...
@@ -8,12 +8,10 @@ public enum AttributeType {
// blocks
// blocks
LOOP
(
false
),
LOOP
(
false
),
CATCH_BLOCK
(
false
),
CATCH_BLOCK
(
false
),
EXC_HANDLER
(
true
),
EXC_HANDLER
(
true
),
SPLITTER_BLOCK
(
true
),
SPLITTER_BLOCK
(
true
),
FORCE_RETURN
(
true
),
FORCE_RETURN
(
true
),
// fields
// fields
...
@@ -32,8 +30,25 @@ public enum AttributeType {
...
@@ -32,8 +30,25 @@ public enum AttributeType {
DECLARE_VARIABLE
(
true
);
DECLARE_VARIABLE
(
true
);
private
static
final
int
notUniqCount
;
private
final
boolean
uniq
;
private
final
boolean
uniq
;
static
{
// place all not unique attributes at first
int
last
=
-
1
;
AttributeType
[]
vals
=
AttributeType
.
values
();
for
(
int
i
=
0
;
i
<
vals
.
length
;
i
++)
{
AttributeType
type
=
vals
[
i
];
if
(
type
.
notUniq
())
last
=
i
;
}
notUniqCount
=
last
+
1
;
}
public
static
int
getNotUniqCount
()
{
return
notUniqCount
;
}
private
AttributeType
(
boolean
isUniq
)
{
private
AttributeType
(
boolean
isUniq
)
{
this
.
uniq
=
isUniq
;
this
.
uniq
=
isUniq
;
}
}
...
...
src/main/java/jadx/dex/attributes/AttributesList.java
浏览文件 @
56eac437
...
@@ -14,6 +14,12 @@ import java.util.List;
...
@@ -14,6 +14,12 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
/**
* Storage for different attribute types:
* 1. flags - boolean attribute (set or not)
* 2. attribute - class instance associated for attribute type,
* only one attached to node for unique attributes, multiple for others
*/
public
class
AttributesList
{
public
class
AttributesList
{
private
final
Set
<
AttributeFlag
>
flags
;
private
final
Set
<
AttributeFlag
>
flags
;
...
@@ -24,16 +30,11 @@ public class AttributesList {
...
@@ -24,16 +30,11 @@ public class AttributesList {
public
AttributesList
()
{
public
AttributesList
()
{
flags
=
EnumSet
.
noneOf
(
AttributeFlag
.
class
);
flags
=
EnumSet
.
noneOf
(
AttributeFlag
.
class
);
uniqAttr
=
new
EnumMap
<
AttributeType
,
IAttribute
>(
AttributeType
.
class
);
uniqAttr
=
new
EnumMap
<
AttributeType
,
IAttribute
>(
AttributeType
.
class
);
attributes
=
new
ArrayList
<
IAttribute
>(
1
);
attributes
=
new
ArrayList
<
IAttribute
>(
0
);
attrCount
=
new
int
[
AttributeType
.
values
().
length
];
attrCount
=
new
int
[
AttributeType
.
getNotUniqCount
()
];
}
}
public
void
add
(
IAttribute
attr
)
{
// Flags
if
(
attr
.
getType
().
isUniq
())
uniqAttr
.
put
(
attr
.
getType
(),
attr
);
else
addMultiAttribute
(
attr
);
}
public
void
add
(
AttributeFlag
flag
)
{
public
void
add
(
AttributeFlag
flag
)
{
flags
.
add
(
flag
);
flags
.
add
(
flag
);
...
@@ -47,12 +48,21 @@ public class AttributesList {
...
@@ -47,12 +48,21 @@ public class AttributesList {
flags
.
remove
(
flag
);
flags
.
remove
(
flag
);
}
}
// Attributes
public
void
add
(
IAttribute
attr
)
{
if
(
attr
.
getType
().
isUniq
())
uniqAttr
.
put
(
attr
.
getType
(),
attr
);
else
addMultiAttribute
(
attr
);
}
private
void
addMultiAttribute
(
IAttribute
attr
)
{
private
void
addMultiAttribute
(
IAttribute
attr
)
{
attributes
.
add
(
attr
);
attributes
.
add
(
attr
);
attrCount
[
attr
.
getType
().
ordinal
()]++;
attrCount
[
attr
.
getType
().
ordinal
()]++;
}
}
private
int
getCountInternal
(
AttributeType
type
)
{
private
int
get
Multi
CountInternal
(
AttributeType
type
)
{
return
attrCount
[
type
.
ordinal
()];
return
attrCount
[
type
.
ordinal
()];
}
}
...
@@ -67,15 +77,14 @@ public class AttributesList {
...
@@ -67,15 +77,14 @@ public class AttributesList {
if
(
type
.
isUniq
())
if
(
type
.
isUniq
())
return
uniqAttr
.
containsKey
(
type
);
return
uniqAttr
.
containsKey
(
type
);
else
else
return
getCountInternal
(
type
)
!=
0
;
return
get
Multi
CountInternal
(
type
)
!=
0
;
}
}
public
IAttribute
get
(
AttributeType
type
)
{
public
IAttribute
get
(
AttributeType
type
)
{
if
(
type
.
isUniq
())
{
if
(
type
.
isUniq
())
{
return
uniqAttr
.
get
(
type
);
return
uniqAttr
.
get
(
type
);
}
else
{
}
else
{
int
count
=
getCountInternal
(
type
);
if
(
getMultiCountInternal
(
type
)
!=
0
)
{
if
(
count
!=
0
)
{
for
(
IAttribute
attr
:
attributes
)
for
(
IAttribute
attr
:
attributes
)
if
(
attr
.
getType
()
==
type
)
if
(
attr
.
getType
()
==
type
)
return
attr
;
return
attr
;
...
@@ -86,9 +95,9 @@ public class AttributesList {
...
@@ -86,9 +95,9 @@ public class AttributesList {
public
int
getCount
(
AttributeType
type
)
{
public
int
getCount
(
AttributeType
type
)
{
if
(
type
.
isUniq
())
{
if
(
type
.
isUniq
())
{
return
0
;
return
uniqAttr
.
containsKey
(
type
)
?
1
:
0
;
}
else
{
}
else
{
return
getCountInternal
(
type
);
return
get
Multi
CountInternal
(
type
);
}
}
}
}
...
@@ -103,7 +112,7 @@ public class AttributesList {
...
@@ -103,7 +112,7 @@ public class AttributesList {
public
List
<
IAttribute
>
getAll
(
AttributeType
type
)
{
public
List
<
IAttribute
>
getAll
(
AttributeType
type
)
{
assert
type
.
notUniq
();
assert
type
.
notUniq
();
int
count
=
getCountInternal
(
type
);
int
count
=
get
Multi
CountInternal
(
type
);
if
(
count
==
0
)
{
if
(
count
==
0
)
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
else
{
}
else
{
...
@@ -129,6 +138,26 @@ public class AttributesList {
...
@@ -129,6 +138,26 @@ public class AttributesList {
}
}
}
}
public
void
remove
(
IAttribute
attr
)
{
AttributeType
type
=
attr
.
getType
();
if
(
type
.
isUniq
())
{
IAttribute
a
=
uniqAttr
.
get
(
type
);
if
(
a
==
attr
)
uniqAttr
.
remove
(
type
);
}
else
{
if
(
getMultiCountInternal
(
type
)
==
0
)
return
;
for
(
Iterator
<
IAttribute
>
it
=
attributes
.
iterator
();
it
.
hasNext
();)
{
IAttribute
a
=
it
.
next
();
if
(
a
==
attr
)
{
it
.
remove
();
attrCount
[
type
.
ordinal
()]--;
}
}
}
}
public
void
clear
()
{
public
void
clear
()
{
flags
.
clear
();
flags
.
clear
();
uniqAttr
.
clear
();
uniqAttr
.
clear
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录