Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ql04210214
jadx
提交
2ad73927
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,发现更多精彩内容 >>
提交
2ad73927
编写于
8月 04, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: handle special values for numbers
上级
caad7888
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
136 addition
and
18 deletion
+136
-18
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
+72
-18
jadx-core/src/test/java/jadx/tests/internal/arith/TestSpecialValues.java
...est/java/jadx/tests/internal/arith/TestSpecialValues.java
+64
-0
未找到文件。
jadx-core/src/main/java/jadx/core/codegen/TypeGen.java
浏览文件 @
2ad73927
...
...
@@ -66,37 +66,91 @@ public class TypeGen {
}
public
static
String
formatShort
(
short
s
)
{
return
"(short) "
+
wrapNegNum
(
s
<
0
,
Short
.
toString
(
s
));
if
(
s
==
Short
.
MAX_VALUE
)
{
return
"Short.MAX_VALUE"
;
}
if
(
s
==
Short
.
MIN_VALUE
)
{
return
"Short.MIN_VALUE"
;
}
return
"(short) "
+
Short
.
toString
(
s
);
}
public
static
String
formatByte
(
byte
b
)
{
return
"(byte) "
+
wrapNegNum
(
b
<
0
,
Byte
.
toString
(
b
));
if
(
b
==
Byte
.
MAX_VALUE
)
{
return
"Byte.MAX_VALUE"
;
}
if
(
b
==
Byte
.
MIN_VALUE
)
{
return
"Byte.MIN_VALUE"
;
}
return
"(byte) "
+
Byte
.
toString
(
b
);
}
public
static
String
formatInteger
(
int
i
)
{
return
wrapNegNum
(
i
<
0
,
Integer
.
toString
(
i
));
if
(
i
==
Integer
.
MAX_VALUE
)
{
return
"Integer.MAX_VALUE"
;
}
if
(
i
==
Integer
.
MIN_VALUE
)
{
return
"Integer.MIN_VALUE"
;
}
return
Integer
.
toString
(
i
);
}
public
static
String
formatDouble
(
double
d
)
{
return
wrapNegNum
(
d
<
0
,
Double
.
toString
(
d
)
+
"d"
);
public
static
String
formatLong
(
long
l
)
{
if
(
l
==
Long
.
MAX_VALUE
)
{
return
"Long.MAX_VALUE"
;
}
if
(
l
==
Long
.
MIN_VALUE
)
{
return
"Long.MIN_VALUE"
;
}
String
str
=
Long
.
toString
(
l
);
if
(
Math
.
abs
(
l
)
>=
Integer
.
MAX_VALUE
)
{
str
+=
"L"
;
}
return
str
;
}
public
static
String
formatFloat
(
float
f
)
{
return
wrapNegNum
(
f
<
0
,
Float
.
toString
(
f
)
+
"f"
);
public
static
String
formatDouble
(
double
d
)
{
if
(
Double
.
isNaN
(
d
))
{
return
"Double.NaN"
;
}
if
(
d
==
Double
.
NEGATIVE_INFINITY
)
{
return
"Double.NEGATIVE_INFINITY"
;
}
if
(
d
==
Double
.
POSITIVE_INFINITY
)
{
return
"Double.POSITIVE_INFINITY"
;
}
if
(
d
==
Double
.
MIN_VALUE
)
{
return
"Double.MIN_VALUE"
;
}
if
(
d
==
Double
.
MAX_VALUE
)
{
return
"Double.MAX_VALUE"
;
}
if
(
d
==
Double
.
MIN_NORMAL
)
{
return
"Double.MIN_NORMAL"
;
}
return
Double
.
toString
(
d
)
+
"d"
;
}
public
static
String
formatLong
(
long
lit
)
{
String
l
=
Long
.
toString
(
lit
);
if
(
lit
==
Long
.
MIN_VALUE
||
Math
.
abs
(
lit
)
>=
Integer
.
MAX_VALUE
)
{
l
+=
"L"
;
public
static
String
formatFloat
(
float
f
)
{
if
(
Float
.
isNaN
(
f
))
{
return
"Float.NaN"
;
}
if
(
f
==
Float
.
NEGATIVE_INFINITY
)
{
return
"Float.NEGATIVE_INFINITY"
;
}
return
wrapNegNum
(
lit
<
0
,
l
);
if
(
f
==
Float
.
POSITIVE_INFINITY
)
{
return
"Float.POSITIVE_INFINITY"
;
}
if
(
f
==
Float
.
MIN_VALUE
)
{
return
"Float.MIN_VALUE"
;
}
if
(
f
==
Float
.
MAX_VALUE
)
{
return
"Float.MAX_VALUE"
;
}
if
(
f
==
Float
.
MIN_NORMAL
)
{
return
"Float.MIN_NORMAL"
;
}
return
Float
.
toString
(
f
)
+
"f"
;
}
private
static
String
wrapNegNum
(
boolean
lz
,
String
str
)
{
// if (lz)
// return "(" + str + ")";
// else
return
str
;
}
}
jadx-core/src/test/java/jadx/tests/internal/arith/TestSpecialValues.java
0 → 100644
浏览文件 @
2ad73927
package
jadx.tests.internal.arith
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestSpecialValues
extends
InternalJadxTest
{
public
static
class
TestCls
{
public
void
test
()
{
shorts
(
Short
.
MIN_VALUE
,
Short
.
MAX_VALUE
);
bytes
(
Byte
.
MIN_VALUE
,
Byte
.
MAX_VALUE
);
ints
(
Integer
.
MIN_VALUE
,
Integer
.
MAX_VALUE
);
longs
(
Long
.
MIN_VALUE
,
Long
.
MAX_VALUE
);
floats
(
Float
.
NaN
,
Float
.
NEGATIVE_INFINITY
,
Float
.
POSITIVE_INFINITY
,
Float
.
MIN_VALUE
,
Float
.
MAX_VALUE
,
Float
.
MIN_NORMAL
);
doubles
(
Double
.
NaN
,
Double
.
NEGATIVE_INFINITY
,
Double
.
POSITIVE_INFINITY
,
Double
.
MIN_VALUE
,
Double
.
MAX_VALUE
,
Double
.
MIN_NORMAL
);
}
private
void
shorts
(
short
...
v
)
{
}
private
void
bytes
(
byte
...
v
)
{
}
private
void
ints
(
int
...
v
)
{
}
private
void
longs
(
long
...
v
)
{
}
private
void
floats
(
float
...
v
)
{
}
private
void
doubles
(
double
...
v
)
{
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
"Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, "
+
"Float.MIN_VALUE, Float.MAX_VALUE, Float.MIN_NORMAL"
));
assertThat
(
code
,
containsOne
(
"Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, "
+
"Double.MIN_VALUE, Double.MAX_VALUE, Double.MIN_NORMAL"
));
assertThat
(
code
,
containsOne
(
"Short.MIN_VALUE, Short.MAX_VALUE"
));
assertThat
(
code
,
containsOne
(
"Byte.MIN_VALUE, Byte.MAX_VALUE"
));
assertThat
(
code
,
containsOne
(
"Integer.MIN_VALUE, Integer.MAX_VALUE"
));
assertThat
(
code
,
containsOne
(
"Long.MIN_VALUE, Long.MAX_VALUE"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录