File tree Expand file tree Collapse file tree 1 file changed +73
-1
lines changed Expand file tree Collapse file tree 1 file changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -1731,7 +1731,46 @@ def f5():
1731
1731
L0:
1732
1732
return 4
1733
1733
1734
- [case testI64Cast]
1734
+ [case testI64OperationsWithBools]
1735
+ from mypy_extensions import i64
1736
+
1737
+ # TODO: Other mixed operations
1738
+
1739
+ def add_bool_to_int(n: i64, b: bool) -> i64:
1740
+ return n + b
1741
+
1742
+ def compare_bool_to_i64(n: i64, b: bool) -> bool:
1743
+ if n == b:
1744
+ return b != n
1745
+ return True
1746
+ [out]
1747
+ def add_bool_to_int(n, b):
1748
+ n :: int64
1749
+ b :: bool
1750
+ r0, r1 :: int64
1751
+ L0:
1752
+ r0 = extend b: builtins.bool to int64
1753
+ r1 = n + r0
1754
+ return r1
1755
+ def compare_bool_to_i64(n, b):
1756
+ n :: int64
1757
+ b :: bool
1758
+ r0 :: int64
1759
+ r1 :: bit
1760
+ r2 :: int64
1761
+ r3 :: bit
1762
+ L0:
1763
+ r0 = extend b: builtins.bool to int64
1764
+ r1 = n == r0
1765
+ if r1 goto L1 else goto L2 :: bool
1766
+ L1:
1767
+ r2 = extend b: builtins.bool to int64
1768
+ r3 = r2 != n
1769
+ return r3
1770
+ L2:
1771
+ return 1
1772
+
1773
+ [case testI64Cast_64bit]
1735
1774
from typing import cast
1736
1775
from mypy_extensions import i64
1737
1776
@@ -1772,6 +1811,39 @@ L2:
1772
1811
L3:
1773
1812
return r3
1774
1813
1814
+ [case testI64Cast_32bit]
1815
+ from typing import cast
1816
+ from mypy_extensions import i64
1817
+
1818
+ def cast_int(x: int) -> i64:
1819
+ return cast(i64, x)
1820
+ [out]
1821
+ def cast_int(x):
1822
+ x :: int
1823
+ r0 :: native_int
1824
+ r1 :: bit
1825
+ r2, r3, r4 :: int64
1826
+ r5 :: ptr
1827
+ r6 :: c_ptr
1828
+ r7 :: int64
1829
+ L0:
1830
+ r0 = x & 1
1831
+ r1 = r0 == 0
1832
+ if r1 goto L1 else goto L2 :: bool
1833
+ L1:
1834
+ r2 = extend signed x: builtins.int to int64
1835
+ r3 = r2 >> 1
1836
+ r4 = r3
1837
+ goto L3
1838
+ L2:
1839
+ r5 = x ^ 1
1840
+ r6 = r5
1841
+ r7 = CPyLong_AsInt64(r6)
1842
+ r4 = r7
1843
+ keep_alive x
1844
+ L3:
1845
+ return r4
1846
+
1775
1847
[case testI64ExplicitConversionFromVariousTypes]
1776
1848
from mypy_extensions import i64
1777
1849
You can’t perform that action at this time.
0 commit comments