-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathirbuild-classes.test
More file actions
2904 lines (2659 loc) · 63.6 KB
/
irbuild-classes.test
File metadata and controls
2904 lines (2659 loc) · 63.6 KB
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
[case testGetAttribute]
class A:
x: int
def f(a: A) -> int:
return a.x
[out]
def f(a):
a :: __main__.A
r0 :: int
L0:
r0 = a.x
return r0
[case testSetAttribute]
class A:
x: int
def f(a: A) -> None:
a.x = 1
[out]
def f(a):
a :: __main__.A
r0 :: bool
L0:
a.x = 2; r0 = is_error
return 1
[case testUserClassInList]
class C:
x: int
def f() -> int:
c = C()
c.x = 5
a = [c]
d = a[0]
return d.x + 1
[out]
def f():
r0, c :: __main__.C
r1 :: bool
r2 :: list
r3 :: ptr
a :: list
r4 :: object
r5, d :: __main__.C
r6, r7 :: int
L0:
r0 = C()
c = r0
c.x = 10; r1 = is_error
r2 = PyList_New(1)
r3 = list_items r2
buf_init_item r3, 0, c
keep_alive r2
a = r2
r4 = CPyList_GetItemShort(a, 0)
r5 = cast(__main__.C, r4)
d = r5
r6 = borrow d.x
r7 = CPyTagged_Add(r6, 2)
keep_alive d
return r7
[case testMethodCall]
class A:
def f(self, x: int, y: str) -> int:
return x + 10
def g(a: A) -> None:
a.f(1, 'hi')
[out]
def A.f(self, x, y):
self :: __main__.A
x :: int
y :: str
r0 :: int
L0:
r0 = CPyTagged_Add(x, 20)
return r0
def g(a):
a :: __main__.A
r0 :: str
r1 :: int
L0:
r0 = 'hi'
r1 = a.f(2, r0)
return 1
[case testForwardUse]
def g(a: A) -> int:
return a.n
class A:
n : int
[out]
def g(a):
a :: __main__.A
r0 :: int
L0:
r0 = a.n
return r0
[case testOptionalMember]
from typing import Optional
class Node:
next: Optional[Node]
def length(self) -> int:
if self.next is not None:
return 1 + self.next.length()
return 1
[out]
def Node.length(self):
self :: __main__.Node
r0 :: union[__main__.Node, None]
r1 :: object
r2 :: bit
r3 :: union[__main__.Node, None]
r4 :: __main__.Node
r5, r6 :: int
L0:
r0 = borrow self.next
r1 = load_address _Py_NoneStruct
r2 = r0 != r1
keep_alive self
if r2 goto L1 else goto L2 :: bool
L1:
r3 = self.next
r4 = cast(__main__.Node, r3)
r5 = r4.length()
r6 = CPyTagged_Add(2, r5)
return r6
L2:
return 2
[case testSubclass]
class A:
def __init__(self) -> None:
self.x = 10
class B(A):
def __init__(self) -> None:
self.x = 20
self.y = 30
[out]
def A.__init__(self):
self :: __main__.A
L0:
self.x = 20
return 1
def B.__init__(self):
self :: __main__.B
L0:
self.x = 40
self.y = 60
return 1
[case testAttrLvalue]
class O(object):
def __init__(self) -> None:
self.x = 1
def increment(o: O) -> O:
o.x += 1
return o
[out]
def O.__init__(self):
self :: __main__.O
L0:
self.x = 2
return 1
def increment(o):
o :: __main__.O
r0, r1 :: int
r2 :: bool
L0:
r0 = borrow o.x
r1 = CPyTagged_Add(r0, 2)
o.x = r1; r2 = is_error
return o
[case testSubclass_withgil_toplevel]
from typing import TypeVar, Generic
from mypy_extensions import trait
T = TypeVar('T')
class C:
pass
@trait
class S:
pass
class D(C, S, Generic[T]):
pass
[out]
def __top_level__():
r0, r1 :: object
r2 :: bit
r3 :: str
r4, r5 :: object
r6 :: str
r7 :: dict
r8, r9 :: object
r10 :: str
r11 :: dict
r12 :: object
r13 :: str
r14 :: dict
r15 :: str
r16 :: object
r17 :: object[1]
r18 :: object_ptr
r19 :: object
r20 :: dict
r21 :: str
r22 :: i32
r23 :: bit
r24 :: object
r25 :: str
r26, r27 :: object
r28 :: bool
r29 :: str
r30 :: tuple
r31 :: i32
r32 :: bit
r33 :: dict
r34 :: str
r35 :: i32
r36 :: bit
r37 :: object
r38 :: str
r39, r40 :: object
r41 :: str
r42 :: tuple
r43 :: i32
r44 :: bit
r45 :: dict
r46 :: str
r47 :: i32
r48 :: bit
r49, r50 :: object
r51 :: dict
r52 :: str
r53 :: object
r54 :: dict
r55 :: str
r56, r57 :: object
r58 :: tuple
r59 :: str
r60, r61 :: object
r62 :: bool
r63, r64 :: str
r65 :: tuple
r66 :: i32
r67 :: bit
r68 :: dict
r69 :: str
r70 :: i32
r71 :: bit
L0:
r0 = builtins :: module
r1 = load_address _Py_NoneStruct
r2 = r0 != r1
if r2 goto L2 else goto L1 :: bool
L1:
r3 = 'builtins'
r4 = PyImport_Import(r3)
builtins = r4 :: module
L2:
r5 = ('TypeVar', 'Generic')
r6 = 'typing'
r7 = __main__.globals :: static
r8 = CPyImport_ImportFromMany(r6, r5, r5, r7)
typing = r8 :: module
r9 = ('trait',)
r10 = 'mypy_extensions'
r11 = __main__.globals :: static
r12 = CPyImport_ImportFromMany(r10, r9, r9, r11)
mypy_extensions = r12 :: module
r13 = 'T'
r14 = __main__.globals :: static
r15 = 'TypeVar'
r16 = CPyDict_GetItem(r14, r15)
r17 = [r13]
r18 = load_address r17
r19 = PyObject_Vectorcall(r16, r18, 1, 0)
keep_alive r13
r20 = __main__.globals :: static
r21 = 'T'
r22 = CPyDict_SetItem(r20, r21, r19)
r23 = r22 >= 0 :: signed
r24 = <error> :: object
r25 = '__main__'
r26 = __main__.C_template :: type
r27 = CPyType_FromTemplate(r26, r24, r25)
r28 = C_trait_vtable_setup()
r29 = '__mypyc_attrs__'
r30 = CPyTuple_LoadEmptyTupleConstant()
r31 = PyObject_SetAttr(r27, r29, r30)
r32 = r31 >= 0 :: signed
__main__.C = r27 :: type
r33 = __main__.globals :: static
r34 = 'C'
r35 = PyDict_SetItem(r33, r34, r27)
r36 = r35 >= 0 :: signed
r37 = <error> :: object
r38 = '__main__'
r39 = __main__.S_template :: type
r40 = CPyType_FromTemplate(r39, r37, r38)
r41 = '__mypyc_attrs__'
r42 = CPyTuple_LoadEmptyTupleConstant()
r43 = PyObject_SetAttr(r40, r41, r42)
r44 = r43 >= 0 :: signed
__main__.S = r40 :: type
r45 = __main__.globals :: static
r46 = 'S'
r47 = PyDict_SetItem(r45, r46, r40)
r48 = r47 >= 0 :: signed
r49 = __main__.C :: type
r50 = __main__.S :: type
r51 = __main__.globals :: static
r52 = 'Generic'
r53 = CPyDict_GetItem(r51, r52)
r54 = __main__.globals :: static
r55 = 'T'
r56 = CPyDict_GetItem(r54, r55)
r57 = PyObject_GetItem(r53, r56)
r58 = PyTuple_Pack(3, r49, r50, r57)
r59 = '__main__'
r60 = __main__.D_template :: type
r61 = CPyType_FromTemplate(r60, r58, r59)
r62 = D_trait_vtable_setup()
r63 = '__mypyc_attrs__'
r64 = '__dict__'
r65 = PyTuple_Pack(1, r64)
r66 = PyObject_SetAttr(r61, r63, r65)
r67 = r66 >= 0 :: signed
__main__.D = r61 :: type
r68 = __main__.globals :: static
r69 = 'D'
r70 = PyDict_SetItem(r68, r69, r61)
r71 = r70 >= 0 :: signed
return 1
[case testIsInstance]
class A: pass
class B(A): pass
def f(x: A) -> B:
if isinstance(x, B):
return x
return B()
[out]
def f(x):
x :: __main__.A
r0 :: object
r1 :: ptr
r2 :: object
r3 :: bit
r4, r5 :: __main__.B
L0:
r0 = __main__.B :: type
r1 = get_element_ptr x ob_type :: PyObject
r2 = borrow load_mem r1 :: builtins.object*
keep_alive x
r3 = r2 == r0
if r3 goto L1 else goto L2 :: bool
L1:
r4 = cast(__main__.B, x)
return r4
L2:
r5 = B()
return r5
[case testIsInstanceTuple]
from typing import Union
class R: pass
class A(R): pass
class B(R): pass
class C(R): pass
def f(x: R) -> Union[A, B]:
if isinstance(x, (A, B)):
return x
return A()
[out]
def f(x):
x :: __main__.R
r0 :: object
r1 :: ptr
r2 :: object
r3 :: bit
r4 :: bool
r5 :: object
r6 :: ptr
r7 :: object
r8 :: bit
r9 :: union[__main__.A, __main__.B]
r10 :: __main__.A
L0:
r0 = __main__.A :: type
r1 = get_element_ptr x ob_type :: PyObject
r2 = borrow load_mem r1 :: builtins.object*
keep_alive x
r3 = r2 == r0
if r3 goto L1 else goto L2 :: bool
L1:
r4 = r3
goto L3
L2:
r5 = __main__.B :: type
r6 = get_element_ptr x ob_type :: PyObject
r7 = borrow load_mem r6 :: builtins.object*
keep_alive x
r8 = r7 == r5
r4 = r8
L3:
if r4 goto L4 else goto L5 :: bool
L4:
r9 = cast(union[__main__.A, __main__.B], x)
return r9
L5:
r10 = A()
return r10
[case testIsInstanceFewSubclasses]
class R: pass
class A(R): pass
def f(x: object) -> R:
if isinstance(x, R):
return x
return A()
[out]
def f(x):
x, r0 :: object
r1 :: ptr
r2 :: object
r3 :: bit
r4 :: bool
r5 :: object
r6 :: ptr
r7 :: object
r8 :: bit
r9 :: __main__.R
r10 :: __main__.A
L0:
r0 = __main__.A :: type
r1 = get_element_ptr x ob_type :: PyObject
r2 = borrow load_mem r1 :: builtins.object*
keep_alive x
r3 = r2 == r0
if r3 goto L1 else goto L2 :: bool
L1:
r4 = r3
goto L3
L2:
r5 = __main__.R :: type
r6 = get_element_ptr x ob_type :: PyObject
r7 = borrow load_mem r6 :: builtins.object*
keep_alive x
r8 = r7 == r5
r4 = r8
L3:
if r4 goto L4 else goto L5 :: bool
L4:
r9 = cast(__main__.R, x)
return r9
L5:
r10 = A()
return r10
[case testIsInstanceFewSubclassesTrait]
from mypy_extensions import trait
class B: pass
@trait
class R: pass
class A(B, R): pass
class C(B, R): pass
def f(x: object) -> R:
if isinstance(x, R):
return x
return A()
[out]
def f(x):
x, r0 :: object
r1 :: ptr
r2 :: object
r3 :: bit
r4 :: bool
r5 :: object
r6 :: ptr
r7 :: object
r8 :: bit
r9 :: __main__.R
r10 :: __main__.A
L0:
r0 = __main__.A :: type
r1 = get_element_ptr x ob_type :: PyObject
r2 = borrow load_mem r1 :: builtins.object*
keep_alive x
r3 = r2 == r0
if r3 goto L1 else goto L2 :: bool
L1:
r4 = r3
goto L3
L2:
r5 = __main__.C :: type
r6 = get_element_ptr x ob_type :: PyObject
r7 = borrow load_mem r6 :: builtins.object*
keep_alive x
r8 = r7 == r5
r4 = r8
L3:
if r4 goto L4 else goto L5 :: bool
L4:
r9 = cast(__main__.R, x)
return r9
L5:
r10 = A()
return r10
[case testIsInstanceManySubclasses]
class R: pass
class A(R): pass
class B(R): pass
class C(R): pass
def f(x: object) -> R:
if isinstance(x, R):
return x
return B()
[out]
def f(x):
x, r0 :: object
r1 :: bool
r2 :: __main__.R
r3 :: __main__.B
L0:
r0 = __main__.R :: type
r1 = CPy_TypeCheck(x, r0)
if r1 goto L1 else goto L2 :: bool
L1:
r2 = cast(__main__.R, x)
return r2
L2:
r3 = B()
return r3
[case testFakeSuper]
class A:
def __init__(self, x: int) -> None:
self.x = x
class B(A):
def __init__(self, x: int, y: int) -> None:
A.__init__(self, x)
self.y = y
[out]
def A.__init__(self, x):
self :: __main__.A
x :: int
L0:
self.x = x
return 1
def B.__init__(self, x, y):
self :: __main__.B
x, y :: int
r0 :: None
L0:
r0 = A.__init__(self, x)
self.y = y
return 1
[case testClassMethod]
class C:
@staticmethod
def foo(x: int) -> int: return 10 + x
@classmethod
def bar(cls, x: int) -> int: return 10 + x
def lol() -> int:
return C.foo(1) + C.bar(2)
[out]
def C.foo(x):
x, r0 :: int
L0:
r0 = CPyTagged_Add(20, x)
return r0
def C.bar(cls, x):
cls :: object
x, r0 :: int
L0:
r0 = CPyTagged_Add(20, x)
return r0
def lol():
r0 :: int
r1 :: object
r2, r3 :: int
L0:
r0 = C.foo(2)
r1 = __main__.C :: type
r2 = C.bar(r1, 4)
r3 = CPyTagged_Add(r0, r2)
return r3
[case testCallClassMethodViaCls_64bit]
class C:
@classmethod
def f(cls, x: int) -> int:
return cls.g(x)
@classmethod
def g(cls, x: int) -> int:
return x
class D:
@classmethod
def f(cls, x: int) -> int:
# TODO: This could also be optimized, since g is not ever overridden
return cls.g(x)
@classmethod
def g(cls, x: int) -> int:
return x
class DD(D):
pass
[out]
def C.f(cls, x):
cls :: object
x :: int
r0 :: object
r1 :: int
L0:
r0 = __main__.C :: type
r1 = C.g(r0, x)
return r1
def C.g(cls, x):
cls :: object
x :: int
L0:
return x
def D.f(cls, x):
cls :: object
x :: int
r0 :: str
r1 :: object
r2 :: object[2]
r3 :: object_ptr
r4 :: object
r5 :: int
L0:
r0 = 'g'
r1 = box(int, x)
r2 = [cls, r1]
r3 = load_address r2
r4 = PyObject_VectorcallMethod(r0, r3, 9223372036854775810, 0)
keep_alive cls, r1
r5 = unbox(int, r4)
return r5
def D.g(cls, x):
cls :: object
x :: int
L0:
return x
[case testCannotAssignToClsArgument]
from typing import Any, cast
class C:
@classmethod
def m(cls) -> None:
cls = cast(Any, D) # E: Cannot assign to the first argument of classmethod
cls, x = cast(Any, D), 1 # E: Cannot assign to the first argument of classmethod
cls, x = cast(Any, [1, 2]) # E: Cannot assign to the first argument of classmethod
cls.m()
class D:
pass
[case testSuper1]
class A:
def __init__(self, x: int) -> None:
self.x = x
class B(A):
def __init__(self, x: int, y: int) -> None:
super().__init__(x)
self.y = y
[out]
def A.__init__(self, x):
self :: __main__.A
x :: int
L0:
self.x = x
return 1
def B.__init__(self, x, y):
self :: __main__.B
x, y :: int
r0 :: None
L0:
r0 = A.__init__(self, x)
self.y = y
return 1
[case testSuper2]
from mypy_extensions import trait
@trait
class T:
def foo(self) -> None: pass
class X(T):
def foo(self) -> None:
super().foo()
[out]
def T.foo(self):
self :: __main__.T
L0:
return 1
def X.foo(self):
self :: __main__.X
r0 :: None
L0:
r0 = T.foo(self)
return 1
[case testSuperCallToObjectInitIsOmitted]
class C:
def __init__(self) -> None:
super().__init__()
class D: pass
class E(D):
def __init__(self) -> None:
super().__init__()
class F(C):
def __init__(self) -> None:
super().__init__()
class DictSubclass(dict):
def __init__(self) -> None:
super().__init__()
[out]
def C.__init__(self):
self :: __main__.C
L0:
return 1
def E.__init__(self):
self :: __main__.E
L0:
return 1
def F.__init__(self):
self :: __main__.F
r0 :: None
L0:
r0 = C.__init__(self)
return 1
def DictSubclass.__init__(self):
self :: dict
r0 :: object
r1 :: str
r2, r3 :: object
r4 :: object[2]
r5 :: object_ptr
r6 :: object
r7 :: str
r8, r9 :: object
L0:
r0 = builtins :: module
r1 = 'super'
r2 = CPyObject_GetAttr(r0, r1)
r3 = __main__.DictSubclass :: type
r4 = [r3, self]
r5 = load_address r4
r6 = PyObject_Vectorcall(r2, r5, 2, 0)
keep_alive r3, self
r7 = '__init__'
r8 = CPyObject_GetAttr(r6, r7)
r9 = PyObject_Vectorcall(r8, 0, 0, 0)
return 1
[case testClassVariable]
from typing import ClassVar
class A:
x = 10 # type: ClassVar[int]
def f() -> int:
return A.x
[out]
def f():
r0 :: object
r1 :: str
r2 :: object
r3 :: int
L0:
r0 = __main__.A :: type
r1 = 'x'
r2 = CPyObject_GetAttr(r0, r1)
r3 = unbox(int, r2)
return r3
[case testNoEqDefined]
class A:
pass
def f(a: A, b: A) -> bool:
return a == b
def f2(a: A, b: A) -> bool:
return a != b
[out]
def f(a, b):
a, b :: __main__.A
r0 :: bit
L0:
r0 = a == b
return r0
def f2(a, b):
a, b :: __main__.A
r0 :: bit
L0:
r0 = a != b
return r0
[case testEqDefined]
class Base:
def __eq__(self, other: object) -> bool:
return False
class Derived(Base):
def __eq__(self, other: object) -> bool:
return True
def f(a: Base, b: Base) -> bool:
return a == b
def f2(a: Base, b: Base) -> bool:
return a != b
def fOpt(a: Derived, b: Derived) -> bool:
return a == b
def fOpt2(a: Derived, b: Derived) -> bool:
return a != b
[out]
def Base.__eq__(self, other):
self :: __main__.Base
other, r0 :: object
L0:
r0 = box(bool, 0)
return r0
def Base.__ne__(__mypyc_self__, rhs):
__mypyc_self__ :: __main__.Base
rhs, r0, r1 :: object
r2 :: bit
r3 :: object
r4, r5 :: bit
r6 :: object
r7 :: bit
r8 :: i32
r9 :: bit
r10 :: bool
r11 :: object
L0:
r0 = __mypyc_self__.__eq__(rhs)
r1 = load_address _Py_NotImplementedStruct
r2 = r0 == r1
if r2 goto L7 else goto L1 :: bool
L1:
r3 = load_global Py_True :: static
r4 = r0 == r3
if r4 goto L2 else goto L3 :: bool
L2:
r5 = 0
goto L6
L3:
r6 = load_global Py_False :: static
r7 = r0 == r6
if r7 goto L4 else goto L5 :: bool
L4:
r5 = 1
goto L6
L5:
r8 = PyObject_Not(r0)
r9 = r8 >= 0 :: signed
r10 = truncate r8: i32 to builtins.bool
r5 = r10
L6:
r11 = box(bit, r5)
return r11
L7:
return r1
def Derived.__eq__(self, other):
self :: __main__.Derived
other, r0 :: object
L0:
r0 = box(bool, 1)
return r0
def f(a, b):
a, b :: __main__.Base
r0 :: object
r1 :: bool
L0:
r0 = PyObject_RichCompare(a, b, 2)
r1 = unbox(bool, r0)
return r1
def f2(a, b):
a, b :: __main__.Base
r0 :: object
r1 :: bool
L0:
r0 = PyObject_RichCompare(a, b, 3)
r1 = unbox(bool, r0)
return r1
def fOpt(a, b):
a, b :: __main__.Derived
r0 :: object
r1 :: bool
L0:
r0 = a.__eq__(b)
r1 = unbox(bool, r0)
return r1
def fOpt2(a, b):
a, b :: __main__.Derived
r0 :: object
r1 :: bool
L0:
r0 = a.__ne__(b)
r1 = unbox(bool, r0)
return r1
[case testEqDefinedLater_64bit]
def f(a: 'Base', b: 'Base') -> bool:
return a == b
def f2(a: 'Base', b: 'Base') -> bool:
return a != b
def fOpt(a: 'Derived', b: 'Derived') -> bool:
return a == b
def fOpt2(a: 'Derived', b: 'Derived') -> bool:
return a != b
class Base:
pass
class Derived(Base):
def __eq__(self, other: object) -> bool:
return True
[out]
def f(a, b):
a, b :: __main__.Base
r0 :: object
r1 :: bool
L0:
r0 = PyObject_RichCompare(a, b, 2)
r1 = unbox(bool, r0)
return r1
def f2(a, b):
a, b :: __main__.Base
r0 :: object
r1 :: bool
L0:
r0 = PyObject_RichCompare(a, b, 3)
r1 = unbox(bool, r0)
return r1
def fOpt(a, b):
a, b :: __main__.Derived
r0 :: object
r1 :: bool
L0:
r0 = a.__eq__(b)
r1 = unbox(bool, r0)
return r1
def fOpt2(a, b):
a, b :: __main__.Derived
r0 :: str
r1 :: object[2]
r2 :: object_ptr
r3 :: object
r4 :: bool
L0:
r0 = '__ne__'
r1 = [a, b]
r2 = load_address r1
r3 = PyObject_VectorcallMethod(r0, r2, 9223372036854775810, 0)
keep_alive a, b
r4 = unbox(bool, r3)
return r4
def Derived.__eq__(self, other):
self :: __main__.Derived
other, r0 :: object
L0:
r0 = box(bool, 1)
return r0
def Derived.__ne__(__mypyc_self__, rhs):
__mypyc_self__ :: __main__.Derived
rhs, r0, r1 :: object