1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120
|
[case testForInRange]
def f() -> None:
x = 0
for i in range(5):
x = x + i
[out]
def f():
x :: int
r0 :: short_int
i :: int
r1 :: bit
r2 :: int
r3 :: short_int
L0:
x = 0
r0 = 0
i = r0
L1:
r1 = r0 < 10 :: signed
if r1 goto L2 else goto L4 :: bool
L2:
r2 = CPyTagged_Add(x, i)
x = r2
L3:
r3 = r0 + 2
r0 = r3
i = r3
goto L1
L4:
return 1
[case testForInRangeVariableEndIndxe]
def f(a: int) -> None:
for i in range(a):
pass
[out]
def f(a):
a, r0, i :: int
r1 :: native_int
r2 :: bit
r3 :: native_int
r4, r5, r6 :: bit
r7 :: bool
r8 :: bit
r9 :: int
L0:
r0 = 0
i = r0
L1:
r1 = r0 & 1
r2 = r1 == 0
r3 = a & 1
r4 = r3 == 0
r5 = r2 & r4
if r5 goto L2 else goto L3 :: bool
L2:
r6 = r0 < a :: signed
r7 = r6
goto L4
L3:
r8 = CPyTagged_IsLt_(r0, a)
r7 = r8
L4:
if r7 goto L5 else goto L7 :: bool
L5:
L6:
r9 = CPyTagged_Add(r0, 2)
r0 = r9
i = r9
goto L1
L7:
return 1
[case testForInNegativeRange]
def f() -> None:
for i in range(10, 0, -1):
pass
[out]
def f():
r0 :: short_int
i :: int
r1 :: bit
r2 :: short_int
L0:
r0 = 20
i = r0
L1:
r1 = r0 > 0 :: signed
if r1 goto L2 else goto L4 :: bool
L2:
L3:
r2 = r0 + -2
r0 = r2
i = r2
goto L1
L4:
return 1
[case testBreak]
def f() -> None:
n = 0
while n < 5:
break
[out]
def f():
n :: int
r0 :: native_int
r1, r2, r3 :: bit
L0:
n = 0
L1:
r0 = n & 1
r1 = r0 != 0
if r1 goto L2 else goto L3 :: bool
L2:
r2 = CPyTagged_IsLt_(n, 10)
if r2 goto L4 else goto L5 :: bool
L3:
r3 = n < 10 :: signed
if r3 goto L4 else goto L5 :: bool
L4:
L5:
return 1
[case testBreakFor]
def f() -> None:
for n in range(5):
break
[out]
def f():
r0 :: short_int
n :: int
r1 :: bit
r2 :: short_int
L0:
r0 = 0
n = r0
L1:
r1 = r0 < 10 :: signed
if r1 goto L2 else goto L4 :: bool
L2:
goto L4
L3:
r2 = r0 + 2
r0 = r2
n = r2
goto L1
L4:
return 1
[case testBreakNested]
def f() -> None:
n = 0
while n < 5:
while n < 4:
break
break
[out]
def f():
n :: int
r0 :: native_int
r1, r2, r3 :: bit
r4 :: native_int
r5, r6, r7 :: bit
L0:
n = 0
L1:
r0 = n & 1
r1 = r0 != 0
if r1 goto L2 else goto L3 :: bool
L2:
r2 = CPyTagged_IsLt_(n, 10)
if r2 goto L4 else goto L10 :: bool
L3:
r3 = n < 10 :: signed
if r3 goto L4 else goto L10 :: bool
L4:
L5:
r4 = n & 1
r5 = r4 != 0
if r5 goto L6 else goto L7 :: bool
L6:
r6 = CPyTagged_IsLt_(n, 8)
if r6 goto L8 else goto L9 :: bool
L7:
r7 = n < 8 :: signed
if r7 goto L8 else goto L9 :: bool
L8:
L9:
L10:
return 1
[case testContinue]
def f() -> None:
n = 0
while n < 5:
continue
[out]
def f():
n :: int
r0 :: native_int
r1, r2, r3 :: bit
L0:
n = 0
L1:
r0 = n & 1
r1 = r0 != 0
if r1 goto L2 else goto L3 :: bool
L2:
r2 = CPyTagged_IsLt_(n, 10)
if r2 goto L4 else goto L5 :: bool
L3:
r3 = n < 10 :: signed
if r3 goto L4 else goto L5 :: bool
L4:
goto L1
L5:
return 1
[case testContinueFor]
def f() -> None:
for n in range(5):
continue
[out]
def f():
r0 :: short_int
n :: int
r1 :: bit
r2 :: short_int
L0:
r0 = 0
n = r0
L1:
r1 = r0 < 10 :: signed
if r1 goto L2 else goto L4 :: bool
L2:
L3:
r2 = r0 + 2
r0 = r2
n = r2
goto L1
L4:
return 1
[case testContinueNested]
def f() -> None:
n = 0
while n < 5:
while n < 4:
continue
continue
[out]
def f():
n :: int
r0 :: native_int
r1, r2, r3 :: bit
r4 :: native_int
r5, r6, r7 :: bit
L0:
n = 0
L1:
r0 = n & 1
r1 = r0 != 0
if r1 goto L2 else goto L3 :: bool
L2:
r2 = CPyTagged_IsLt_(n, 10)
if r2 goto L4 else goto L10 :: bool
L3:
r3 = n < 10 :: signed
if r3 goto L4 else goto L10 :: bool
L4:
L5:
r4 = n & 1
r5 = r4 != 0
if r5 goto L6 else goto L7 :: bool
L6:
r6 = CPyTagged_IsLt_(n, 8)
if r6 goto L8 else goto L9 :: bool
L7:
r7 = n < 8 :: signed
if r7 goto L8 else goto L9 :: bool
L8:
goto L5
L9:
goto L1
L10:
return 1
[case testForList]
from typing import List
def f(ls: List[int]) -> int:
y = 0
for x in ls:
y = y + x
return y
[out]
def f(ls):
ls :: list
y :: int
r0 :: short_int
r1 :: ptr
r2 :: native_int
r3 :: short_int
r4 :: bit
r5 :: object
r6, x, r7 :: int
r8 :: short_int
L0:
y = 0
r0 = 0
L1:
r1 = get_element_ptr ls ob_size :: PyVarObject
r2 = load_mem r1, ls :: native_int*
r3 = r2 << 1
r4 = r0 < r3 :: signed
if r4 goto L2 else goto L4 :: bool
L2:
r5 = CPyList_GetItemUnsafe(ls, r0)
r6 = unbox(int, r5)
x = r6
r7 = CPyTagged_Add(y, x)
y = r7
L3:
r8 = r0 + 2
r0 = r8
goto L1
L4:
return y
[case testForDictBasic]
from typing import Dict
def f(d: Dict[int, int]) -> None:
for key in d:
d[key]
[out]
def f(d):
d :: dict
r0 :: short_int
r1 :: native_int
r2 :: short_int
r3 :: object
r4 :: tuple[bool, int, object]
r5 :: int
r6 :: bool
r7 :: object
r8, key :: int
r9, r10 :: object
r11 :: int
r12, r13 :: bit
L0:
r0 = 0
r1 = PyDict_Size(d)
r2 = r1 << 1
r3 = CPyDict_GetKeysIter(d)
L1:
r4 = CPyDict_NextKey(r3, r0)
r5 = r4[1]
r0 = r5
r6 = r4[0]
if r6 goto L2 else goto L4 :: bool
L2:
r7 = r4[2]
r8 = unbox(int, r7)
key = r8
r9 = box(int, key)
r10 = CPyDict_GetItem(d, r9)
r11 = unbox(int, r10)
L3:
r12 = CPyDict_CheckSize(d, r2)
goto L1
L4:
r13 = CPy_NoErrOccured()
L5:
return 1
[case testForDictContinue]
from typing import Dict
def sum_over_even_values(d: Dict[int, int]) -> int:
s = 0
for key in d:
if d[key] % 2:
continue
s = s + d[key]
return s
[out]
def sum_over_even_values(d):
d :: dict
s :: int
r0 :: short_int
r1 :: native_int
r2 :: short_int
r3 :: object
r4 :: tuple[bool, int, object]
r5 :: int
r6 :: bool
r7 :: object
r8, key :: int
r9, r10 :: object
r11, r12 :: int
r13 :: bit
r14, r15 :: object
r16, r17 :: int
r18, r19 :: bit
L0:
s = 0
r0 = 0
r1 = PyDict_Size(d)
r2 = r1 << 1
r3 = CPyDict_GetKeysIter(d)
L1:
r4 = CPyDict_NextKey(r3, r0)
r5 = r4[1]
r0 = r5
r6 = r4[0]
if r6 goto L2 else goto L6 :: bool
L2:
r7 = r4[2]
r8 = unbox(int, r7)
key = r8
r9 = box(int, key)
r10 = CPyDict_GetItem(d, r9)
r11 = unbox(int, r10)
r12 = CPyTagged_Remainder(r11, 4)
r13 = r12 != 0
if r13 goto L3 else goto L4 :: bool
L3:
goto L5
L4:
r14 = box(int, key)
r15 = CPyDict_GetItem(d, r14)
r16 = unbox(int, r15)
r17 = CPyTagged_Add(s, r16)
s = r17
L5:
r18 = CPyDict_CheckSize(d, r2)
goto L1
L6:
r19 = CPy_NoErrOccured()
L7:
return s
[case testMultipleAssignmentWithNoUnpacking]
from typing import Tuple
def f(x: int, y: int) -> Tuple[int, int]:
x, y = y, x
return (x, y)
def f2(x: int, y: str, z: float) -> Tuple[float, str, int]:
a, b, c = x, y, z
return (c, b, a)
def f3(x: int, y: int) -> Tuple[int, int]:
[x, y] = [y, x]
return (x, y)
[out]
def f(x, y):
x, y, r0, r1 :: int
r2 :: tuple[int, int]
L0:
r0 = y
r1 = x
x = r0
y = r1
r2 = (x, y)
return r2
def f2(x, y, z):
x :: int
y :: str
z :: float
r0 :: int
r1 :: str
r2 :: float
a :: int
b :: str
c :: float
r3 :: tuple[float, str, int]
L0:
r0 = x
r1 = y
r2 = z
a = r0
b = r1
c = r2
r3 = (c, b, a)
return r3
def f3(x, y):
x, y, r0, r1 :: int
r2 :: tuple[int, int]
L0:
r0 = y
r1 = x
x = r0
y = r1
r2 = (x, y)
return r2
[case testMultipleAssignmentBasicUnpacking]
from typing import Tuple, Any
def from_tuple(t: Tuple[int, str]) -> None:
x, y = t
def from_any(a: Any) -> None:
x, y = a
[out]
def from_tuple(t):
t :: tuple[int, str]
r0, x :: int
r1, y :: str
L0:
r0 = t[0]
x = r0
r1 = t[1]
y = r1
return 1
def from_any(a):
a, r0, r1 :: object
r2 :: bool
x, r3 :: object
r4 :: bool
y, r5 :: object
r6 :: bool
L0:
r0 = PyObject_GetIter(a)
r1 = PyIter_Next(r0)
if is_error(r1) goto L1 else goto L2
L1:
r2 = raise ValueError('not enough values to unpack')
unreachable
L2:
x = r1
r3 = PyIter_Next(r0)
if is_error(r3) goto L3 else goto L4
L3:
r4 = raise ValueError('not enough values to unpack')
unreachable
L4:
y = r3
r5 = PyIter_Next(r0)
if is_error(r5) goto L6 else goto L5
L5:
r6 = raise ValueError('too many values to unpack')
unreachable
L6:
return 1
[case testMultiAssignmentCoercions]
from typing import Tuple, Any
def from_tuple(t: Tuple[int, Any]) -> None:
x: object
y: int
x, y = t
def from_any(a: Any) -> None:
x: int
x, y = a
[out]
def from_tuple(t):
t :: tuple[int, object]
r0 :: int
r1, x, r2 :: object
r3, y :: int
L0:
r0 = t[0]
r1 = box(int, r0)
x = r1
r2 = t[1]
r3 = unbox(int, r2)
y = r3
return 1
def from_any(a):
a, r0, r1 :: object
r2 :: bool
r3, x :: int
r4 :: object
r5 :: bool
y, r6 :: object
r7 :: bool
L0:
r0 = PyObject_GetIter(a)
r1 = PyIter_Next(r0)
if is_error(r1) goto L1 else goto L2
L1:
r2 = raise ValueError('not enough values to unpack')
unreachable
L2:
r3 = unbox(int, r1)
x = r3
r4 = PyIter_Next(r0)
if is_error(r4) goto L3 else goto L4
L3:
r5 = raise ValueError('not enough values to unpack')
unreachable
L4:
y = r4
r6 = PyIter_Next(r0)
if is_error(r6) goto L6 else goto L5
L5:
r7 = raise ValueError('too many values to unpack')
unreachable
L6:
return 1
[case testMultiAssignmentNested]
from typing import Tuple, Any, List
class A:
x: int
def multi_assign(t: Tuple[int, Tuple[str, Any]], a: A, l: List[str]) -> None:
z: int
a.x, (l[0], z) = t
[out]
def multi_assign(t, a, l):
t :: tuple[int, tuple[str, object]]
a :: __main__.A
l :: list
r0 :: int
r1 :: bool
r2 :: tuple[str, object]
r3 :: str
r4 :: bit
r5 :: object
r6, z :: int
L0:
r0 = t[0]
a.x = r0; r1 = is_error
r2 = t[1]
r3 = r2[0]
r4 = CPyList_SetItem(l, 0, r3)
r5 = r2[1]
r6 = unbox(int, r5)
z = r6
return 1
[case testMultipleAssignmentUnpackFromSequence]
from typing import List, Tuple
def f(l: List[int], t: Tuple[int, ...]) -> None:
x: object
y: int
x, y = l
x, y = t
[out]
def f(l, t):
l :: list
t :: tuple
r0 :: int32
r1 :: bit
r2, r3, x :: object
r4, y :: int
r5 :: int32
r6 :: bit
r7, r8 :: object
r9 :: int
L0:
r0 = CPySequence_CheckUnpackCount(l, 2)
r1 = r0 >= 0 :: signed
r2 = CPyList_GetItemUnsafe(l, 0)
r3 = CPyList_GetItemUnsafe(l, 2)
x = r2
r4 = unbox(int, r3)
y = r4
r5 = CPySequence_CheckUnpackCount(t, 2)
r6 = r5 >= 0 :: signed
r7 = CPySequenceTuple_GetItem(t, 0)
r8 = CPySequenceTuple_GetItem(t, 2)
r9 = unbox(int, r8)
x = r7
y = r9
return 1
[case testAssert]
from typing import Optional
def no_msg(x: bool) -> int:
assert x
return 1
def literal_msg(x: object) -> int:
assert x, 'message'
return 2
def complex_msg(x: Optional[str], s: str) -> None:
assert x, s
[out]
def no_msg(x):
x, r0 :: bool
L0:
if x goto L2 else goto L1 :: bool
L1:
r0 = raise AssertionError
unreachable
L2:
return 2
def literal_msg(x):
x :: object
r0 :: int32
r1 :: bit
r2, r3 :: bool
L0:
r0 = PyObject_IsTrue(x)
r1 = r0 >= 0 :: signed
r2 = truncate r0: int32 to builtins.bool
if r2 goto L2 else goto L1 :: bool
L1:
r3 = raise AssertionError('message')
unreachable
L2:
return 4
def complex_msg(x, s):
x :: union[str, None]
s :: str
r0 :: object
r1 :: bit
r2 :: str
r3 :: int32
r4 :: bit
r5 :: bool
r6 :: object
r7 :: str
r8, r9 :: object
L0:
r0 = load_address _Py_NoneStruct
r1 = x != r0
if r1 goto L1 else goto L2 :: bool
L1:
r2 = cast(str, x)
r3 = PyObject_IsTrue(r2)
r4 = r3 >= 0 :: signed
r5 = truncate r3: int32 to builtins.bool
if r5 goto L3 else goto L2 :: bool
L2:
r6 = builtins :: module
r7 = load_global CPyStatic_unicode_3 :: static ('AssertionError')
r8 = CPyObject_GetAttr(r6, r7)
r9 = PyObject_CallFunctionObjArgs(r8, s, 0)
CPy_Raise(r9)
unreachable
L3:
return 1
[case testDelList]
def delList() -> None:
l = [1, 2]
del l[1]
def delListMultiple() -> None:
l = [1, 2, 3, 4, 5, 6, 7]
del l[1], l[2], l[3]
[out]
def delList():
r0 :: list
r1, r2 :: object
r3, r4, r5 :: ptr
l :: list
r6 :: object
r7 :: int32
r8 :: bit
L0:
r0 = PyList_New(2)
r1 = box(short_int, 2)
r2 = box(short_int, 4)
r3 = get_element_ptr r0 ob_item :: PyListObject
r4 = load_mem r3, r0 :: ptr*
set_mem r4, r1, r0 :: builtins.object*
r5 = r4 + WORD_SIZE*1
set_mem r5, r2, r0 :: builtins.object*
l = r0
r6 = box(short_int, 2)
r7 = PyObject_DelItem(l, r6)
r8 = r7 >= 0 :: signed
return 1
def delListMultiple():
r0 :: list
r1, r2, r3, r4, r5, r6, r7 :: object
r8, r9, r10, r11, r12, r13, r14, r15 :: ptr
l :: list
r16 :: object
r17 :: int32
r18 :: bit
r19 :: object
r20 :: int32
r21 :: bit
r22 :: object
r23 :: int32
r24 :: bit
L0:
r0 = PyList_New(7)
r1 = box(short_int, 2)
r2 = box(short_int, 4)
r3 = box(short_int, 6)
r4 = box(short_int, 8)
r5 = box(short_int, 10)
r6 = box(short_int, 12)
r7 = box(short_int, 14)
r8 = get_element_ptr r0 ob_item :: PyListObject
r9 = load_mem r8, r0 :: ptr*
set_mem r9, r1, r0 :: builtins.object*
r10 = r9 + WORD_SIZE*1
set_mem r10, r2, r0 :: builtins.object*
r11 = r9 + WORD_SIZE*2
set_mem r11, r3, r0 :: builtins.object*
r12 = r9 + WORD_SIZE*3
set_mem r12, r4, r0 :: builtins.object*
r13 = r9 + WORD_SIZE*4
set_mem r13, r5, r0 :: builtins.object*
r14 = r9 + WORD_SIZE*5
set_mem r14, r6, r0 :: builtins.object*
r15 = r9 + WORD_SIZE*6
set_mem r15, r7, r0 :: builtins.object*
l = r0
r16 = box(short_int, 2)
r17 = PyObject_DelItem(l, r16)
r18 = r17 >= 0 :: signed
r19 = box(short_int, 4)
r20 = PyObject_DelItem(l, r19)
r21 = r20 >= 0 :: signed
r22 = box(short_int, 6)
r23 = PyObject_DelItem(l, r22)
r24 = r23 >= 0 :: signed
return 1
[case testDelDict]
def delDict() -> None:
d = {"one":1, "two":2}
del d["one"]
def delDictMultiple() -> None:
d = {"one":1, "two":2, "three":3, "four":4}
del d["one"], d["four"]
[out]
def delDict():
r0, r1 :: str
r2, r3 :: object
r4, d :: dict
r5 :: str
r6 :: int32
r7 :: bit
L0:
r0 = load_global CPyStatic_unicode_1 :: static ('one')
r1 = load_global CPyStatic_unicode_2 :: static ('two')
r2 = box(short_int, 2)
r3 = box(short_int, 4)
r4 = CPyDict_Build(2, r0, r2, r1, r3)
d = r4
r5 = load_global CPyStatic_unicode_1 :: static ('one')
r6 = PyObject_DelItem(d, r5)
r7 = r6 >= 0 :: signed
return 1
def delDictMultiple():
r0, r1, r2, r3 :: str
r4, r5, r6, r7 :: object
r8, d :: dict
r9, r10 :: str
r11 :: int32
r12 :: bit
r13 :: int32
r14 :: bit
L0:
r0 = load_global CPyStatic_unicode_1 :: static ('one')
r1 = load_global CPyStatic_unicode_2 :: static ('two')
r2 = load_global CPyStatic_unicode_3 :: static ('three')
r3 = load_global CPyStatic_unicode_4 :: static ('four')
r4 = box(short_int, 2)
r5 = box(short_int, 4)
r6 = box(short_int, 6)
r7 = box(short_int, 8)
r8 = CPyDict_Build(4, r0, r4, r1, r5, r2, r6, r3, r7)
d = r8
r9 = load_global CPyStatic_unicode_1 :: static ('one')
r10 = load_global CPyStatic_unicode_4 :: static ('four')
r11 = PyObject_DelItem(d, r9)
r12 = r11 >= 0 :: signed
r13 = PyObject_DelItem(d, r10)
r14 = r13 >= 0 :: signed
return 1
[case testDelAttribute]
class Dummy():
def __init__(self, x: int, y: int) -> None:
self.x = x
self.y = y
def delAttribute() -> None:
dummy = Dummy(1, 2)
del dummy.x
def delAttributeMultiple() -> None:
dummy = Dummy(1, 2)
del dummy.x, dummy.y
[out]
def Dummy.__init__(self, x, y):
self :: __main__.Dummy
x, y :: int
r0, r1 :: bool
L0:
self.x = x; r0 = is_error
self.y = y; r1 = is_error
return 1
def delAttribute():
r0, dummy :: __main__.Dummy
r1 :: str
r2 :: int32
r3 :: bit
L0:
r0 = Dummy(2, 4)
dummy = r0
r1 = load_global CPyStatic_unicode_3 :: static ('x')
r2 = PyObject_DelAttr(dummy, r1)
r3 = r2 >= 0 :: signed
return 1
def delAttributeMultiple():
r0, dummy :: __main__.Dummy
r1 :: str
r2 :: int32
r3 :: bit
r4 :: str
r5 :: int32
r6 :: bit
L0:
r0 = Dummy(2, 4)
dummy = r0
r1 = load_global CPyStatic_unicode_3 :: static ('x')
r2 = PyObject_DelAttr(dummy, r1)
r3 = r2 >= 0 :: signed
r4 = load_global CPyStatic_unicode_4 :: static ('y')
r5 = PyObject_DelAttr(dummy, r4)
r6 = r5 >= 0 :: signed
return 1
[case testForEnumerate]
from typing import List, Iterable
def f(a: List[int]) -> None:
for i, x in enumerate(a):
i + x
def g(x: Iterable[int]) -> None:
for i, n in enumerate(x):
pass
[out]
def f(a):
a :: list
r0 :: short_int
i :: int
r1 :: short_int
r2 :: ptr
r3 :: native_int
r4 :: short_int
r5 :: bit
r6 :: object
r7, x, r8 :: int
r9, r10 :: short_int
L0:
r0 = 0
i = 0
r1 = 0
L1:
r2 = get_element_ptr a ob_size :: PyVarObject
r3 = load_mem r2, a :: native_int*
r4 = r3 << 1
r5 = r1 < r4 :: signed
if r5 goto L2 else goto L4 :: bool
L2:
r6 = CPyList_GetItemUnsafe(a, r1)
r7 = unbox(int, r6)
x = r7
r8 = CPyTagged_Add(i, x)
L3:
r9 = r0 + 2
r0 = r9
i = r9
r10 = r1 + 2
r1 = r10
goto L1
L4:
L5:
return 1
def g(x):
x :: object
r0 :: short_int
i :: int
r1, r2 :: object
r3, n :: int
r4 :: short_int
r5 :: bit
L0:
r0 = 0
i = 0
r1 = PyObject_GetIter(x)
L1:
r2 = PyIter_Next(r1)
if is_error(r2) goto L4 else goto L2
L2:
r3 = unbox(int, r2)
n = r3
L3:
r4 = r0 + 2
r0 = r4
i = r4
goto L1
L4:
r5 = CPy_NoErrOccured()
L5:
return 1
[case testForZip]
from typing import List, Iterable
def f(a: List[int], b: Iterable[bool]) -> None:
for x, y in zip(a, b):
if b:
x = 1
def g(a: Iterable[bool], b: List[int]) -> None:
for x, y, z in zip(a, b, range(5)):
x = False
[out]
def f(a, b):
a :: list
b :: object
r0 :: short_int
r1 :: object
r2 :: ptr
r3 :: native_int
r4 :: short_int
r5 :: bit
r6, r7 :: object
r8, x :: int
r9, y :: bool
r10 :: int32
r11 :: bit
r12 :: bool
r13 :: short_int
r14 :: bit
L0:
r0 = 0
r1 = PyObject_GetIter(b)
L1:
r2 = get_element_ptr a ob_size :: PyVarObject
r3 = load_mem r2, a :: native_int*
r4 = r3 << 1
r5 = r0 < r4 :: signed
if r5 goto L2 else goto L7 :: bool
L2:
r6 = PyIter_Next(r1)
if is_error(r6) goto L7 else goto L3
L3:
r7 = CPyList_GetItemUnsafe(a, r0)
r8 = unbox(int, r7)
x = r8
r9 = unbox(bool, r6)
y = r9
r10 = PyObject_IsTrue(b)
r11 = r10 >= 0 :: signed
r12 = truncate r10: int32 to builtins.bool
if r12 goto L4 else goto L5 :: bool
L4:
x = 2
L5:
L6:
r13 = r0 + 2
r0 = r13
goto L1
L7:
r14 = CPy_NoErrOccured()
L8:
return 1
def g(a, b):
a :: object
b :: list
r0 :: object
r1, r2 :: short_int
z :: int
r3 :: object
r4 :: ptr
r5 :: native_int
r6 :: short_int
r7, r8 :: bit
r9, x :: bool
r10 :: object
r11, y :: int
r12, r13 :: short_int
r14 :: bit
L0:
r0 = PyObject_GetIter(a)
r1 = 0
r2 = 0
z = r2
L1:
r3 = PyIter_Next(r0)
if is_error(r3) goto L6 else goto L2
L2:
r4 = get_element_ptr b ob_size :: PyVarObject
r5 = load_mem r4, b :: native_int*
r6 = r5 << 1
r7 = r1 < r6 :: signed
if r7 goto L3 else goto L6 :: bool
L3:
r8 = r2 < 10 :: signed
if r8 goto L4 else goto L6 :: bool
L4:
r9 = unbox(bool, r3)
x = r9
r10 = CPyList_GetItemUnsafe(b, r1)
r11 = unbox(int, r10)
y = r11
x = 0
L5:
r12 = r1 + 2
r1 = r12
r13 = r2 + 2
r2 = r13
z = r13
goto L1
L6:
r14 = CPy_NoErrOccured()
L7:
return 1
|