Skip to content

Commit 1f4b0b5

Browse files
author
amimo
committed
if literal constant value in [-2147483648(INT_MIN), 2147483647(INT_MAX)], set it's type to
int, otherwise long. fix issue: 1.update ndk to r19c 2.compile com.test.TestCompiler.Compare#run to c and com.test.TestCompiler.Compare#testLongCompare will fail.
1 parent 183639b commit 1f4b0b5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

dex2c/compiler.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,14 @@ def fix_const_type(self):
286286
for node in nodes:
287287
for ins in node.get_instr_list():
288288
if isinstance(ins, LoadConstant) and ins.get_value_type() is None:
289-
if ins.get_cst().get_constant() > 0x80000000:
290-
Changed = True
291-
logger.debug("Set constant type to long: %s" % ins)
292-
ins.set_value_type('J')
293-
else:
289+
if -2147483648 <= ins.get_cst().get_constant() <= 2147483647:
294290
Changed = True
295291
logger.debug("Set constant type to int: %s" % ins)
296292
ins.set_value_type('I')
293+
else:
294+
Changed = True
295+
logger.debug("Set constant type to long: %s" % ins)
296+
ins.set_value_type('J')
297297

298298
if Changed:
299299
self.infer_type()

0 commit comments

Comments
 (0)