Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colcode
jadx
提交
a6f61151
J
jadx
项目概览
colcode
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
a6f61151
编写于
4月 28, 2013
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix loops processing
上级
533883b5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
66 addition
and
8 deletion
+66
-8
src/main/java/jadx/dex/visitors/regions/RegionMaker.java
src/main/java/jadx/dex/visitors/regions/RegionMaker.java
+16
-8
src/main/java/jadx/utils/BlockUtils.java
src/main/java/jadx/utils/BlockUtils.java
+10
-0
src/samples/java/jadx/samples/TestCF3.java
src/samples/java/jadx/samples/TestCF3.java
+40
-0
未找到文件。
src/main/java/jadx/dex/visitors/regions/RegionMaker.java
浏览文件 @
a6f61151
...
...
@@ -124,17 +124,17 @@ public class RegionMaker {
IfNode
ifnode
=
null
;
LoopRegion
loopRegion
=
null
;
Set
<
BlockNode
>
exitBlocksSet
=
loop
.
getExitNodes
();
// set exit blocks scan order by priority
// this can help if
we have several exit from loop
(after using 'break' or 'return' in loop)
// this can help if
loop have several exits
(after using 'break' or 'return' in loop)
List
<
BlockNode
>
exitBlocks
=
new
ArrayList
<
BlockNode
>(
exitBlocksSet
.
size
());
if
(
exitBlocksSet
.
contains
(
loop
.
getEnd
()))
{
BlockNode
nextStart
=
BlockUtils
.
getNextBlock
(
loopStart
);
if
(
nextStart
!=
null
&&
exitBlocksSet
.
remove
(
nextStart
))
exitBlocks
.
add
(
nextStart
);
if
(
exitBlocksSet
.
remove
(
loop
.
getEnd
()))
exitBlocks
.
add
(
loop
.
getEnd
());
exitBlocksSet
.
remove
(
loop
.
getEnd
());
}
if
(
exitBlocksSet
.
contains
(
loopStart
))
{
if
(
exitBlocksSet
.
remove
(
loopStart
))
exitBlocks
.
add
(
loopStart
);
exitBlocksSet
.
remove
(
loopStart
);
}
exitBlocks
.
addAll
(
exitBlocksSet
);
exitBlocksSet
=
null
;
...
...
@@ -189,7 +189,11 @@ public class RegionMaker {
stack
.
pop
();
loopStart
.
getAttributes
().
add
(
loop
);
return
BlockUtils
.
getNextBlock
(
loop
.
getEnd
());
BlockNode
next
=
BlockUtils
.
getNextBlock
(
loop
.
getEnd
());
if
(!
RegionUtils
.
isRegionContainsBlock
(
body
,
next
))
return
next
;
else
return
null
;
}
stack
.
push
(
loopRegion
);
...
...
@@ -372,6 +376,10 @@ public class RegionMaker {
}
}
if
(
BlockUtils
.
isBackEdge
(
block
,
out
))
{
out
=
null
;
}
if
(
stack
.
containsExit
(
elseBlock
))
elseBlock
=
null
;
...
...
src/main/java/jadx/utils/BlockUtils.java
浏览文件 @
a6f61151
...
...
@@ -48,6 +48,16 @@ public class BlockUtils {
return
ret
;
}
public
static
boolean
isBackEdge
(
BlockNode
from
,
BlockNode
to
)
{
if
(
from
.
getCleanSuccessors
().
contains
(
to
))
return
false
;
// already checked
if
(!
from
.
getSuccessors
().
contains
(
to
))
return
false
;
// not even successor
return
true
;
}
/**
* Remove exception handlers from block nodes bitset
*/
...
...
src/samples/java/jadx/samples/TestCF3.java
浏览文件 @
a6f61151
...
...
@@ -18,6 +18,10 @@ public class TestCF3 extends AbstractTest {
return
1
;
}
private
int
exc
()
throws
Exception
{
return
1
;
}
public
void
testSwitchInLoop
()
throws
Exception
{
while
(
true
)
{
int
n
=
next
();
...
...
@@ -103,6 +107,31 @@ public class TestCF3 extends AbstractTest {
return
foundIt
;
}
public
String
testReturnInLoop
(
List
<
String
>
list
)
{
Iterator
<
String
>
it
=
list
.
iterator
();
while
(
it
.
hasNext
())
{
String
ver
=
it
.
next
();
if
(
ver
!=
null
)
return
ver
;
}
return
"error"
;
}
public
String
testReturnInLoop2
(
List
<
String
>
list
)
{
try
{
Iterator
<
String
>
it
=
list
.
iterator
();
while
(
it
.
hasNext
())
{
String
ver
=
it
.
next
();
exc
();
if
(
ver
!=
null
)
return
ver
;
}
}
catch
(
Exception
e
)
{
setEnabled
(
false
);
}
return
"error"
;
}
@Override
public
boolean
testRun
()
throws
Exception
{
setEnabled
(
false
);
...
...
@@ -117,6 +146,17 @@ public class TestCF3 extends AbstractTest {
new
ArrayList
<
String
>(
Arrays
.
asList
(
"a1"
,
"a2"
)),
new
ArrayList
<
String
>(
Arrays
.
asList
(
"a1"
,
"b2"
))));
List
<
String
>
list1
=
Arrays
.
asList
(
null
,
"a"
,
"b"
);
// TODO this line required to omit generic information because it create List<Object>
// List<String> list2 = Arrays.asList(null, null, null);
assertEquals
(
testReturnInLoop
(
list1
),
"a"
);
assertEquals
(
testReturnInLoop2
(
list1
),
"a"
);
// assertEquals(testReturnInLoop(list2), "error");
// assertEquals(testReturnInLoop2(list2), "error");
// assertTrue(testLabeledBreakContinue());
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录