@@ -1850,7 +1850,7 @@ pub fn translate_expr(
1850
1850
}
1851
1851
ast:: Expr :: Literal ( lit) => match lit {
1852
1852
ast:: Literal :: Numeric ( val) => {
1853
- if val. starts_with ( "0x" ) {
1853
+ if val. starts_with ( "0x" ) || val . starts_with ( "0X" ) {
1854
1854
// must be a hex decimal
1855
1855
let int_value = i64:: from_str_radix ( & val[ 2 ..] , 16 ) ?;
1856
1856
program. emit_insn ( Insn :: Integer {
@@ -1941,14 +1941,22 @@ pub fn translate_expr(
1941
1941
// Special case: if we're negating "9223372036854775808", this is exactly MIN_INT64
1942
1942
// If we don't do this -1 * 9223372036854775808 will overflow and parse will fail
1943
1943
// and trigger conversion to Real.
1944
- if numeric_value == "9223372036854775808" {
1944
+ if numeric_value == "9223372036854775808"
1945
+ || numeric_value. eq_ignore_ascii_case ( "0x7fffffffffffffff" )
1946
+ {
1945
1947
program. emit_insn ( Insn :: Integer {
1946
1948
value : i64:: MIN ,
1947
1949
dest : target_register,
1948
1950
} ) ;
1949
1951
} else {
1950
- let maybe_int = numeric_value. parse :: < i64 > ( ) ;
1951
- if let Ok ( value) = maybe_int {
1952
+ if numeric_value. starts_with ( "0x" ) || numeric_value. starts_with ( "0X" ) {
1953
+ // must be a hex decimal
1954
+ let int_value = i64:: from_str_radix ( & numeric_value[ 2 ..] , 16 ) ?;
1955
+ program. emit_insn ( Insn :: Integer {
1956
+ value : -int_value,
1957
+ dest : target_register,
1958
+ } ) ;
1959
+ } else if let Ok ( value) = numeric_value. parse :: < i64 > ( ) {
1952
1960
program. emit_insn ( Insn :: Integer {
1953
1961
value : value * -1 ,
1954
1962
dest : target_register,
@@ -1982,8 +1990,13 @@ pub fn translate_expr(
1982
1990
Ok ( target_register)
1983
1991
}
1984
1992
( UnaryOperator :: BitwiseNot , ast:: Expr :: Literal ( ast:: Literal :: Numeric ( num_val) ) ) => {
1985
- let maybe_int = num_val. parse :: < i64 > ( ) ;
1986
- if let Ok ( val) = maybe_int {
1993
+ if num_val. starts_with ( "0x" ) || num_val. starts_with ( "0X" ) {
1994
+ let int_value = i64:: from_str_radix ( & num_val[ 2 ..] , 16 ) ?;
1995
+ program. emit_insn ( Insn :: Integer {
1996
+ value : !int_value,
1997
+ dest : target_register,
1998
+ } ) ;
1999
+ } else if let Ok ( val) = num_val. parse :: < i64 > ( ) {
1987
2000
program. emit_insn ( Insn :: Integer {
1988
2001
value : !val,
1989
2002
dest : target_register,
0 commit comments