-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathirbuild-match.test
More file actions
1835 lines (1805 loc) · 36 KB
/
irbuild-match.test
File metadata and controls
1835 lines (1805 loc) · 36 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 testMatchValuePattern_python3_10]
def f():
match 123:
case 123:
print("matched")
[out]
def f():
r0 :: bit
r1 :: str
r2 :: object
r3 :: str
r4 :: object
r5 :: object[1]
r6 :: object_ptr
r7, r8 :: object
L0:
r0 = int_eq 246, 246
if r0 goto L1 else goto L2 :: bool
L1:
r1 = 'matched'
r2 = builtins :: module
r3 = 'print'
r4 = CPyObject_GetAttr(r2, r3)
r5 = [r1]
r6 = load_address r5
r7 = PyObject_Vectorcall(r4, r6, 1, 0)
keep_alive r1
goto L3
L2:
L3:
r8 = box(None, 1)
return r8
[case testMatchOrPattern_python3_10]
def f():
match 123:
case 123 | 456:
print("matched")
[out]
def f():
r0, r1 :: bit
r2 :: str
r3 :: object
r4 :: str
r5 :: object
r6 :: object[1]
r7 :: object_ptr
r8, r9 :: object
L0:
r0 = int_eq 246, 246
if r0 goto L1 else goto L2 :: bool
L1:
goto L5
L2:
r1 = int_eq 246, 912
if r1 goto L3 else goto L4 :: bool
L3:
goto L5
L4:
goto L6
L5:
r2 = 'matched'
r3 = builtins :: module
r4 = 'print'
r5 = CPyObject_GetAttr(r3, r4)
r6 = [r2]
r7 = load_address r6
r8 = PyObject_Vectorcall(r5, r7, 1, 0)
keep_alive r2
goto L7
L6:
L7:
r9 = box(None, 1)
return r9
[case testMatchOrPatternManyPatterns_python3_10]
def f():
match 1:
case 1 | 2 | 3 | 4:
print("matched")
[out]
def f():
r0, r1, r2, r3 :: bit
r4 :: str
r5 :: object
r6 :: str
r7 :: object
r8 :: object[1]
r9 :: object_ptr
r10, r11 :: object
L0:
r0 = int_eq 2, 2
if r0 goto L1 else goto L2 :: bool
L1:
goto L9
L2:
r1 = int_eq 2, 4
if r1 goto L3 else goto L4 :: bool
L3:
goto L9
L4:
r2 = int_eq 2, 6
if r2 goto L5 else goto L6 :: bool
L5:
goto L9
L6:
r3 = int_eq 2, 8
if r3 goto L7 else goto L8 :: bool
L7:
goto L9
L8:
goto L10
L9:
r4 = 'matched'
r5 = builtins :: module
r6 = 'print'
r7 = CPyObject_GetAttr(r5, r6)
r8 = [r4]
r9 = load_address r8
r10 = PyObject_Vectorcall(r7, r9, 1, 0)
keep_alive r4
goto L11
L10:
L11:
r11 = box(None, 1)
return r11
[case testMatchClassPattern_python3_10]
def f():
match 123:
case int():
print("matched")
[out]
def f():
r0, r1 :: object
r2 :: bool
r3 :: str
r4 :: object
r5 :: str
r6 :: object
r7 :: object[1]
r8 :: object_ptr
r9, r10 :: object
L0:
r0 = load_address PyLong_Type
r1 = object 123
r2 = CPy_TypeCheck(r1, r0)
if r2 goto L1 else goto L2 :: bool
L1:
r3 = 'matched'
r4 = builtins :: module
r5 = 'print'
r6 = CPyObject_GetAttr(r4, r5)
r7 = [r3]
r8 = load_address r7
r9 = PyObject_Vectorcall(r6, r8, 1, 0)
keep_alive r3
goto L3
L2:
L3:
r10 = box(None, 1)
return r10
[case testMatchExhaustivePattern_python3_10]
def f():
match 123:
case _:
print("matched")
[out]
def f():
r0 :: str
r1 :: object
r2 :: str
r3 :: object
r4 :: object[1]
r5 :: object_ptr
r6, r7 :: object
L0:
L1:
r0 = 'matched'
r1 = builtins :: module
r2 = 'print'
r3 = CPyObject_GetAttr(r1, r2)
r4 = [r0]
r5 = load_address r4
r6 = PyObject_Vectorcall(r3, r5, 1, 0)
keep_alive r0
goto L3
L2:
L3:
r7 = box(None, 1)
return r7
[case testMatchMultipleBodies_python3_10]
def f():
match 123:
case 123:
print("matched")
case 456:
print("no match")
[out]
def f():
r0 :: bit
r1 :: str
r2 :: object
r3 :: str
r4 :: object
r5 :: object[1]
r6 :: object_ptr
r7 :: object
r8 :: bit
r9 :: str
r10 :: object
r11 :: str
r12 :: object
r13 :: object[1]
r14 :: object_ptr
r15, r16 :: object
L0:
r0 = int_eq 246, 246
if r0 goto L1 else goto L2 :: bool
L1:
r1 = 'matched'
r2 = builtins :: module
r3 = 'print'
r4 = CPyObject_GetAttr(r2, r3)
r5 = [r1]
r6 = load_address r5
r7 = PyObject_Vectorcall(r4, r6, 1, 0)
keep_alive r1
goto L5
L2:
r8 = int_eq 246, 912
if r8 goto L3 else goto L4 :: bool
L3:
r9 = 'no match'
r10 = builtins :: module
r11 = 'print'
r12 = CPyObject_GetAttr(r10, r11)
r13 = [r9]
r14 = load_address r13
r15 = PyObject_Vectorcall(r12, r14, 1, 0)
keep_alive r9
goto L5
L4:
L5:
r16 = box(None, 1)
return r16
[case testMatchMultiBodyAndComplexOr_python3_10]
def f():
match 123:
case 1:
print("here 1")
case 2 | 3:
print("here 2 | 3")
case 123:
print("here 123")
[out]
def f():
r0 :: bit
r1 :: str
r2 :: object
r3 :: str
r4 :: object
r5 :: object[1]
r6 :: object_ptr
r7 :: object
r8, r9 :: bit
r10 :: str
r11 :: object
r12 :: str
r13 :: object
r14 :: object[1]
r15 :: object_ptr
r16 :: object
r17 :: bit
r18 :: str
r19 :: object
r20 :: str
r21 :: object
r22 :: object[1]
r23 :: object_ptr
r24, r25 :: object
L0:
r0 = int_eq 246, 2
if r0 goto L1 else goto L2 :: bool
L1:
r1 = 'here 1'
r2 = builtins :: module
r3 = 'print'
r4 = CPyObject_GetAttr(r2, r3)
r5 = [r1]
r6 = load_address r5
r7 = PyObject_Vectorcall(r4, r6, 1, 0)
keep_alive r1
goto L11
L2:
r8 = int_eq 246, 4
if r8 goto L3 else goto L4 :: bool
L3:
goto L7
L4:
r9 = int_eq 246, 6
if r9 goto L5 else goto L6 :: bool
L5:
goto L7
L6:
goto L8
L7:
r10 = 'here 2 | 3'
r11 = builtins :: module
r12 = 'print'
r13 = CPyObject_GetAttr(r11, r12)
r14 = [r10]
r15 = load_address r14
r16 = PyObject_Vectorcall(r13, r15, 1, 0)
keep_alive r10
goto L11
L8:
r17 = int_eq 246, 246
if r17 goto L9 else goto L10 :: bool
L9:
r18 = 'here 123'
r19 = builtins :: module
r20 = 'print'
r21 = CPyObject_GetAttr(r19, r20)
r22 = [r18]
r23 = load_address r22
r24 = PyObject_Vectorcall(r21, r23, 1, 0)
keep_alive r18
goto L11
L10:
L11:
r25 = box(None, 1)
return r25
[case testMatchWithGuard_python3_10]
def f():
match 123:
case 123 if True:
print("matched")
[out]
def f():
r0 :: bit
r1 :: str
r2 :: object
r3 :: str
r4 :: object
r5 :: object[1]
r6 :: object_ptr
r7, r8 :: object
L0:
r0 = int_eq 246, 246
if r0 goto L1 else goto L3 :: bool
L1:
if 1 goto L2 else goto L3 :: bool
L2:
r1 = 'matched'
r2 = builtins :: module
r3 = 'print'
r4 = CPyObject_GetAttr(r2, r3)
r5 = [r1]
r6 = load_address r5
r7 = PyObject_Vectorcall(r4, r6, 1, 0)
keep_alive r1
goto L4
L3:
L4:
r8 = box(None, 1)
return r8
[case testMatchSingleton_python3_10]
def f():
match 123:
case True:
print("value is True")
case False:
print("value is False")
case None:
print("value is None")
[out]
def f():
r0, r1 :: object
r2 :: bit
r3 :: str
r4 :: object
r5 :: str
r6 :: object
r7 :: object[1]
r8 :: object_ptr
r9, r10, r11 :: object
r12 :: bit
r13 :: str
r14 :: object
r15 :: str
r16 :: object
r17 :: object[1]
r18 :: object_ptr
r19, r20, r21 :: object
r22 :: bit
r23 :: str
r24 :: object
r25 :: str
r26 :: object
r27 :: object[1]
r28 :: object_ptr
r29, r30 :: object
L0:
r0 = object 123
r1 = box(bool, 1)
r2 = r0 == r1
if r2 goto L1 else goto L2 :: bool
L1:
r3 = 'value is True'
r4 = builtins :: module
r5 = 'print'
r6 = CPyObject_GetAttr(r4, r5)
r7 = [r3]
r8 = load_address r7
r9 = PyObject_Vectorcall(r6, r8, 1, 0)
keep_alive r3
goto L7
L2:
r10 = object 123
r11 = box(bool, 0)
r12 = r10 == r11
if r12 goto L3 else goto L4 :: bool
L3:
r13 = 'value is False'
r14 = builtins :: module
r15 = 'print'
r16 = CPyObject_GetAttr(r14, r15)
r17 = [r13]
r18 = load_address r17
r19 = PyObject_Vectorcall(r16, r18, 1, 0)
keep_alive r13
goto L7
L4:
r20 = load_address _Py_NoneStruct
r21 = object 123
r22 = r21 == r20
if r22 goto L5 else goto L6 :: bool
L5:
r23 = 'value is None'
r24 = builtins :: module
r25 = 'print'
r26 = CPyObject_GetAttr(r24, r25)
r27 = [r23]
r28 = load_address r27
r29 = PyObject_Vectorcall(r26, r28, 1, 0)
keep_alive r23
goto L7
L6:
L7:
r30 = box(None, 1)
return r30
[case testMatchRecursiveOrPattern_python3_10]
def f():
match 1:
case 1 | int():
print("matched")
[out]
def f():
r0 :: bit
r1, r2 :: object
r3 :: bool
r4 :: str
r5 :: object
r6 :: str
r7 :: object
r8 :: object[1]
r9 :: object_ptr
r10, r11 :: object
L0:
r0 = int_eq 2, 2
if r0 goto L1 else goto L2 :: bool
L1:
goto L5
L2:
r1 = load_address PyLong_Type
r2 = object 1
r3 = CPy_TypeCheck(r2, r1)
if r3 goto L3 else goto L4 :: bool
L3:
goto L5
L4:
goto L6
L5:
r4 = 'matched'
r5 = builtins :: module
r6 = 'print'
r7 = CPyObject_GetAttr(r5, r6)
r8 = [r4]
r9 = load_address r8
r10 = PyObject_Vectorcall(r7, r9, 1, 0)
keep_alive r4
goto L7
L6:
L7:
r11 = box(None, 1)
return r11
[case testMatchAsPattern_python3_10]
def f():
match 123:
case 123 as x:
print(x)
[out]
def f():
r0 :: bit
r1, x, r2 :: object
r3 :: str
r4 :: object
r5 :: object[1]
r6 :: object_ptr
r7, r8 :: object
L0:
r0 = int_eq 246, 246
r1 = object 123
x = r1
if r0 goto L1 else goto L2 :: bool
L1:
r2 = builtins :: module
r3 = 'print'
r4 = CPyObject_GetAttr(r2, r3)
r5 = [x]
r6 = load_address r5
r7 = PyObject_Vectorcall(r4, r6, 1, 0)
keep_alive x
goto L3
L2:
L3:
r8 = box(None, 1)
return r8
[case testMatchAsPatternOnOrPattern_python3_10]
def f():
match 1:
case (1 | 2) as x:
print(x)
[out]
def f():
r0 :: bit
r1, x :: object
r2 :: bit
r3, r4 :: object
r5 :: str
r6 :: object
r7 :: object[1]
r8 :: object_ptr
r9, r10 :: object
L0:
r0 = int_eq 2, 2
r1 = object 1
x = r1
if r0 goto L1 else goto L2 :: bool
L1:
goto L5
L2:
r2 = int_eq 2, 4
r3 = object 2
x = r3
if r2 goto L3 else goto L4 :: bool
L3:
goto L5
L4:
goto L6
L5:
r4 = builtins :: module
r5 = 'print'
r6 = CPyObject_GetAttr(r4, r5)
r7 = [x]
r8 = load_address r7
r9 = PyObject_Vectorcall(r6, r8, 1, 0)
keep_alive x
goto L7
L6:
L7:
r10 = box(None, 1)
return r10
[case testMatchAsPatternOnClassPattern_python3_10]
def f():
match 123:
case int() as i:
print(i)
[out]
def f():
r0, r1 :: object
r2 :: bool
r3, i, r4 :: object
r5 :: str
r6 :: object
r7 :: object[1]
r8 :: object_ptr
r9, r10 :: object
L0:
r0 = load_address PyLong_Type
r1 = object 123
r2 = CPy_TypeCheck(r1, r0)
if r2 goto L1 else goto L3 :: bool
L1:
r3 = object 123
i = r3
L2:
r4 = builtins :: module
r5 = 'print'
r6 = CPyObject_GetAttr(r4, r5)
r7 = [i]
r8 = load_address r7
r9 = PyObject_Vectorcall(r6, r8, 1, 0)
keep_alive i
goto L4
L3:
L4:
r10 = box(None, 1)
return r10
[case testMatchClassPatternWithPositionalArgs_python3_10]
class Position:
__match_args__ = ("x", "y", "z")
x: int
y: int
z: int
def f(x) -> None:
match x:
case Position(1, 2, 3):
print("matched")
[out]
def Position.__mypyc_defaults_setup(__mypyc_self__):
__mypyc_self__ :: __main__.Position
r0, r1, r2 :: str
r3 :: tuple[str, str, str]
L0:
r0 = 'x'
r1 = 'y'
r2 = 'z'
r3 = (r0, r1, r2)
__mypyc_self__.__match_args__ = r3
return 1
def f(x):
x, r0 :: object
r1 :: i32
r2 :: bit
r3 :: bool
r4 :: str
r5, r6, r7 :: object
r8 :: i32
r9 :: bit
r10 :: bool
r11 :: str
r12, r13, r14 :: object
r15 :: i32
r16 :: bit
r17 :: bool
r18 :: str
r19, r20, r21 :: object
r22 :: i32
r23 :: bit
r24 :: bool
r25 :: str
r26 :: object
r27 :: str
r28 :: object
r29 :: object[1]
r30 :: object_ptr
r31 :: object
L0:
r0 = __main__.Position :: type
r1 = PyObject_IsInstance(x, r0)
r2 = r1 >= 0 :: signed
r3 = truncate r1: i32 to builtins.bool
if r3 goto L1 else goto L5 :: bool
L1:
r4 = 'x'
r5 = CPyObject_GetAttr(x, r4)
r6 = object 1
r7 = PyObject_RichCompare(r5, r6, 2)
r8 = PyObject_IsTrue(r7)
r9 = r8 >= 0 :: signed
r10 = truncate r8: i32 to builtins.bool
if r10 goto L2 else goto L5 :: bool
L2:
r11 = 'y'
r12 = CPyObject_GetAttr(x, r11)
r13 = object 2
r14 = PyObject_RichCompare(r12, r13, 2)
r15 = PyObject_IsTrue(r14)
r16 = r15 >= 0 :: signed
r17 = truncate r15: i32 to builtins.bool
if r17 goto L3 else goto L5 :: bool
L3:
r18 = 'z'
r19 = CPyObject_GetAttr(x, r18)
r20 = object 3
r21 = PyObject_RichCompare(r19, r20, 2)
r22 = PyObject_IsTrue(r21)
r23 = r22 >= 0 :: signed
r24 = truncate r22: i32 to builtins.bool
if r24 goto L4 else goto L5 :: bool
L4:
r25 = 'matched'
r26 = builtins :: module
r27 = 'print'
r28 = CPyObject_GetAttr(r26, r27)
r29 = [r25]
r30 = load_address r29
r31 = PyObject_Vectorcall(r28, r30, 1, 0)
keep_alive r25
goto L6
L5:
L6:
return 1
[case testMatchClassPatternWithKeywordPatterns_python3_10]
class Position:
x: int
y: int
z: int
def f(x):
match x:
case Position(z=1, y=2, x=3):
print("matched")
[out]
def f(x):
x, r0 :: object
r1 :: i32
r2 :: bit
r3 :: bool
r4 :: str
r5, r6, r7 :: object
r8 :: i32
r9 :: bit
r10 :: bool
r11 :: str
r12, r13, r14 :: object
r15 :: i32
r16 :: bit
r17 :: bool
r18 :: str
r19, r20, r21 :: object
r22 :: i32
r23 :: bit
r24 :: bool
r25 :: str
r26 :: object
r27 :: str
r28 :: object
r29 :: object[1]
r30 :: object_ptr
r31, r32 :: object
L0:
r0 = __main__.Position :: type
r1 = PyObject_IsInstance(x, r0)
r2 = r1 >= 0 :: signed
r3 = truncate r1: i32 to builtins.bool
if r3 goto L1 else goto L5 :: bool
L1:
r4 = 'z'
r5 = CPyObject_GetAttr(x, r4)
r6 = object 1
r7 = PyObject_RichCompare(r5, r6, 2)
r8 = PyObject_IsTrue(r7)
r9 = r8 >= 0 :: signed
r10 = truncate r8: i32 to builtins.bool
if r10 goto L2 else goto L5 :: bool
L2:
r11 = 'y'
r12 = CPyObject_GetAttr(x, r11)
r13 = object 2
r14 = PyObject_RichCompare(r12, r13, 2)
r15 = PyObject_IsTrue(r14)
r16 = r15 >= 0 :: signed
r17 = truncate r15: i32 to builtins.bool
if r17 goto L3 else goto L5 :: bool
L3:
r18 = 'x'
r19 = CPyObject_GetAttr(x, r18)
r20 = object 3
r21 = PyObject_RichCompare(r19, r20, 2)
r22 = PyObject_IsTrue(r21)
r23 = r22 >= 0 :: signed
r24 = truncate r22: i32 to builtins.bool
if r24 goto L4 else goto L5 :: bool
L4:
r25 = 'matched'
r26 = builtins :: module
r27 = 'print'
r28 = CPyObject_GetAttr(r26, r27)
r29 = [r25]
r30 = load_address r29
r31 = PyObject_Vectorcall(r28, r30, 1, 0)
keep_alive r25
goto L6
L5:
L6:
r32 = box(None, 1)
return r32
[case testMatchClassPatternWithNestedPattern_python3_10]
class C:
num: int
def f(x):
match x:
case C(num=1 | 2):
print("matched")
[out]
def f(x):
x, r0 :: object
r1 :: i32
r2 :: bit
r3 :: bool
r4 :: str
r5, r6, r7 :: object
r8 :: i32
r9 :: bit
r10 :: bool
r11, r12 :: object
r13 :: i32
r14 :: bit
r15 :: bool
r16 :: str
r17 :: object
r18 :: str
r19 :: object
r20 :: object[1]
r21 :: object_ptr
r22, r23 :: object
L0:
r0 = __main__.C :: type
r1 = PyObject_IsInstance(x, r0)
r2 = r1 >= 0 :: signed
r3 = truncate r1: i32 to builtins.bool
if r3 goto L1 else goto L7 :: bool
L1:
r4 = 'num'
r5 = CPyObject_GetAttr(x, r4)
r6 = object 1
r7 = PyObject_RichCompare(r5, r6, 2)
r8 = PyObject_IsTrue(r7)
r9 = r8 >= 0 :: signed
r10 = truncate r8: i32 to builtins.bool
if r10 goto L2 else goto L3 :: bool
L2:
goto L6
L3:
r11 = object 2
r12 = PyObject_RichCompare(r5, r11, 2)
r13 = PyObject_IsTrue(r12)
r14 = r13 >= 0 :: signed
r15 = truncate r13: i32 to builtins.bool
if r15 goto L4 else goto L5 :: bool
L4:
goto L6
L5:
goto L7
L6:
r16 = 'matched'
r17 = builtins :: module
r18 = 'print'
r19 = CPyObject_GetAttr(r17, r18)
r20 = [r16]
r21 = load_address r20
r22 = PyObject_Vectorcall(r19, r21, 1, 0)
keep_alive r16
goto L8
L7:
L8:
r23 = box(None, 1)
return r23
[case testAsPatternDoesntBleedIntoSubPatterns_python3_10]
class C:
__match_args__ = ("a", "b")
a: int
b: int
def f(x) -> None:
match x:
case C(1, 2) as y:
print("matched")
[out]
def C.__mypyc_defaults_setup(__mypyc_self__):
__mypyc_self__ :: __main__.C
r0, r1 :: str
r2 :: tuple[str, str]
L0:
r0 = 'a'
r1 = 'b'
r2 = (r0, r1)
__mypyc_self__.__match_args__ = r2
return 1
def f(x):
x, r0 :: object
r1 :: i32
r2 :: bit
r3 :: bool
r4, y :: __main__.C
r5 :: str
r6, r7, r8 :: object
r9 :: i32
r10 :: bit
r11 :: bool
r12 :: str
r13, r14, r15 :: object
r16 :: i32
r17 :: bit
r18 :: bool
r19 :: str
r20 :: object
r21 :: str
r22 :: object
r23 :: object[1]
r24 :: object_ptr
r25 :: object
L0:
r0 = __main__.C :: type
r1 = PyObject_IsInstance(x, r0)
r2 = r1 >= 0 :: signed
r3 = truncate r1: i32 to builtins.bool
if r3 goto L1 else goto L5 :: bool
L1:
r4 = cast(__main__.C, x)
y = r4
L2:
r5 = 'a'
r6 = CPyObject_GetAttr(x, r5)
r7 = object 1
r8 = PyObject_RichCompare(r6, r7, 2)
r9 = PyObject_IsTrue(r8)
r10 = r9 >= 0 :: signed
r11 = truncate r9: i32 to builtins.bool
if r11 goto L3 else goto L5 :: bool
L3:
r12 = 'b'
r13 = CPyObject_GetAttr(x, r12)
r14 = object 2
r15 = PyObject_RichCompare(r13, r14, 2)
r16 = PyObject_IsTrue(r15)
r17 = r16 >= 0 :: signed
r18 = truncate r16: i32 to builtins.bool
if r18 goto L4 else goto L5 :: bool
L4:
r19 = 'matched'
r20 = builtins :: module
r21 = 'print'
r22 = CPyObject_GetAttr(r20, r21)
r23 = [r19]
r24 = load_address r23
r25 = PyObject_Vectorcall(r22, r24, 1, 0)
keep_alive r19
goto L6
L5:
L6:
return 1
[case testMatchClassPatternPositionalCapture_python3_10]
class C:
__match_args__ = ("x",)
x: int
def f(x):
match x:
case C(num):
print("matched")
[out]
def C.__mypyc_defaults_setup(__mypyc_self__):
__mypyc_self__ :: __main__.C
r0 :: str
r1 :: tuple[str]
L0:
r0 = 'x'
r1 = (r0)
__mypyc_self__.__match_args__ = r1
return 1
def f(x):
x, r0 :: object
r1 :: i32
r2 :: bit
r3 :: bool
r4 :: str
r5, num :: object
r6 :: str
r7 :: object
r8 :: str
r9 :: object
r10 :: object[1]
r11 :: object_ptr
r12, r13 :: object
L0:
r0 = __main__.C :: type
r1 = PyObject_IsInstance(x, r0)
r2 = r1 >= 0 :: signed
r3 = truncate r1: i32 to builtins.bool
if r3 goto L1 else goto L3 :: bool
L1:
r4 = 'x'