@@ -782,28 +782,27 @@ asm(
782
782
".ascii \" for bit in range(0, type_mask_size):\\n\"\n"
783
783
".ascii \" if type_mask & (1 << bit):\\n\"\n"
784
784
".ascii \" type_name = ZendTypeBits.zendTypeName(bit)\\n\"\n"
785
- ".ascii \" match type_name:\\n\"\n"
786
- ".ascii \" case None:\\n\"\n"
787
- ".ascii \" parts.append('(1<<%d)' % bit)\\n\"\n"
788
- ".ascii \" case 'list':\\n\"\n"
789
- ".ascii \" list = t['ptr'].cast(gdb.lookup_type('zend_type_list').pointer())\\n\"\n"
790
- ".ascii \" num_types = int(list['num_types'])\\n\"\n"
791
- ".ascii \" types = list['types'].dereference().cast(gdb.lookup_type('zend_type').array(num_types))\\n\"\n"
792
- ".ascii \" for i in range(0, num_types):\\n\"\n"
793
- ".ascii \" str = self.format_type(types[i])\\n\"\n"
794
- ".ascii \" if any((c in set('|&()')) for c in str):\\n\"\n"
795
- ".ascii \" str = '(%s)' % str\\n\"\n"
796
- ".ascii \" parts.append(str)\\n\"\n"
797
- ".ascii \" case 'union' | 'arena':\\n\"\n"
798
- ".ascii \" meta.append(type_name)\\n\"\n"
799
- ".ascii \" case 'intersection':\\n\"\n"
800
- ".ascii \" meta.append(type_name)\\n\"\n"
801
- ".ascii \" separator = '&'\\n\"\n"
802
- ".ascii \" case 'name':\\n\"\n"
803
- ".ascii \" str = t['ptr'].cast(gdb.lookup_type('zend_string').pointer())\\n\"\n"
804
- ".ascii \" parts.append(format_zstr(str))\\n\"\n"
805
- ".ascii \" case _:\\n\"\n"
806
- ".ascii \" parts.append(type_name)\\n\"\n"
785
+ ".ascii \" if type_name is None:\\n\"\n"
786
+ ".ascii \" parts.append('(1<<%d)' % bit)\\n\"\n"
787
+ ".ascii \" elif type_name == 'list':\\n\"\n"
788
+ ".ascii \" list_ptr = t['ptr'].cast(gdb.lookup_type('zend_type_list').pointer())\\n\"\n"
789
+ ".ascii \" num_types = int(list_ptr['num_types'])\\n\"\n"
790
+ ".ascii \" types = list_ptr['types'].dereference().cast(gdb.lookup_type('zend_type').array(num_types))\\n\"\n"
791
+ ".ascii \" for i in range(0, num_types):\\n\"\n"
792
+ ".ascii \" type_str = self.format_type(types[i])\\n\"\n"
793
+ ".ascii \" if any((c in set('|&()')) for c in type_str):\\n\"\n"
794
+ ".ascii \" type_str = '(%s)' % type_str\\n\"\n"
795
+ ".ascii \" parts.append(type_str)\\n\"\n"
796
+ ".ascii \" elif type_name == 'union' or type_name == 'arena':\\n\"\n"
797
+ ".ascii \" meta.append(type_name)\\n\"\n"
798
+ ".ascii \" elif type_name == 'intersection':\\n\"\n"
799
+ ".ascii \" meta.append(type_name)\\n\"\n"
800
+ ".ascii \" separator = '&'\\n\"\n"
801
+ ".ascii \" elif type_name == 'name':\\n\"\n"
802
+ ".ascii \" name_str = t['ptr'].cast(gdb.lookup_type('zend_string').pointer())\\n\"\n"
803
+ ".ascii \" parts.append(format_zstr(name_str))\\n\"\n"
804
+ ".ascii \" else:\\n\"\n"
805
+ ".ascii \" parts.append(type_name)\\n\"\n"
807
806
".ascii \"\\n\"\n"
808
807
".ascii \" str = separator.join(parts)\\n\"\n"
809
808
".ascii \"\\n\"\n"
@@ -1073,15 +1072,15 @@ asm(
1073
1072
".ascii \" self.val = val\\n\"\n"
1074
1073
".ascii \"\\n\"\n"
1075
1074
".ascii \" def to_string(self):\\n\"\n"
1076
- ".ascii \" match int(self.val['type']): \\n\"\n"
1077
- ".ascii \" case ZendFnTypes.ZEND_INTERNAL_FUNCTION:\\n\"\n"
1078
- ".ascii \" typestr = 'internal'\\n\"\n"
1079
- ".ascii \" case ZendFnTypes.ZEND_USER_FUNCTION:\\n\"\n"
1080
- ".ascii \" typestr = 'user'\\n\"\n"
1081
- ".ascii \" case ZendFnTypes.ZEND_EVAL_CODE:\\n\"\n"
1082
- ".ascii \" typestr = 'eval'\\n\"\n"
1083
- ".ascii \" case _ :\\n\"\n"
1084
- ".ascii \" typestr = '\?\?\?'\\n\"\n"
1075
+ ".ascii \" val_type = int(self.val['type'])\\n\"\n"
1076
+ ".ascii \" if val_type == ZendFnTypes.ZEND_INTERNAL_FUNCTION:\\n\"\n"
1077
+ ".ascii \" typestr = 'internal'\\n\"\n"
1078
+ ".ascii \" elif val_type == ZendFnTypes.ZEND_USER_FUNCTION:\\n\"\n"
1079
+ ".ascii \" typestr = 'user'\\n\"\n"
1080
+ ".ascii \" elif val_type == ZendFnTypes.ZEND_EVAL_CODE:\\n\"\n"
1081
+ ".ascii \" typestr = 'eval'\\n\"\n"
1082
+ ".ascii \" else :\\n\"\n"
1083
+ ".ascii \" typestr = '\?\?\?'\\n\"\n"
1085
1084
".ascii \"\\n\"\n"
1086
1085
".ascii \" if self.val['common']['function_name']:\\n\"\n"
1087
1086
".ascii \" namestr = format_zstr(self.val['common']['function_name'])\\n\"\n"
@@ -1501,13 +1500,12 @@ asm(
1501
1500
".ascii \"\\n\"\n"
1502
1501
".ascii \" bits = self._bits\\n\"\n"
1503
1502
".ascii \" type_bits = None\\n\"\n"
1504
- ".ascii \" match type_name:\\n\"\n"
1505
- ".ascii \" case 'string':\\n\"\n"
1506
- ".ascii \" type_bits = self._str_bits\\n\"\n"
1507
- ".ascii \" case 'array':\\n\"\n"
1508
- ".ascii \" type_bits = self._array_bits\\n\"\n"
1509
- ".ascii \" case 'object':\\n\"\n"
1510
- ".ascii \" type_bits = self._obj_bits\\n\"\n"
1503
+ ".ascii \" if type_name == 'string':\\n\"\n"
1504
+ ".ascii \" type_bits = self._str_bits\\n\"\n"
1505
+ ".ascii \" elif type_name == 'array':\\n\"\n"
1506
+ ".ascii \" type_bits = self._array_bits\\n\"\n"
1507
+ ".ascii \" elif type_name == 'object':\\n\"\n"
1508
+ ".ascii \" type_bits = self._obj_bits\\n\"\n"
1511
1509
".ascii \"\\n\"\n"
1512
1510
".ascii \" type_flags = flags & self._flags_mask\\n\"\n"
1513
1511
".ascii \" for i in range(0, 31):\\n\"\n"
@@ -1530,15 +1528,14 @@ asm(
1530
1528
".ascii \"\\n\"\n"
1531
1529
".ascii \" if (flags & (1<<self.bit('GC_NOT_COLLECTABLE'))) == 0:\\n\"\n"
1532
1530
".ascii \" gc_color = (flags >> self._info_shift) & self._gc_color\\n\"\n"
1533
- ".ascii \" match gc_color:\\n\"\n"
1534
- ".ascii \" case self._gc_black:\\n\"\n"
1535
- ".ascii \" names.append('GC_BLACK')\\n\"\n"
1536
- ".ascii \" case self._gc_white:\\n\"\n"
1537
- ".ascii \" names.append('GC_WHITE')\\n\"\n"
1538
- ".ascii \" case self._gc_grey:\\n\"\n"
1539
- ".ascii \" names.append('GC_GREY')\\n\"\n"
1540
- ".ascii \" case self._gc_purple:\\n\"\n"
1541
- ".ascii \" names.append('GC_PURPLE')\\n\"\n"
1531
+ ".ascii \" if gc_color == self._gc_black:\\n\"\n"
1532
+ ".ascii \" names.append('GC_BLACK')\\n\"\n"
1533
+ ".ascii \" elif gc_color == self._gc_white:\\n\"\n"
1534
+ ".ascii \" names.append('GC_WHITE')\\n\"\n"
1535
+ ".ascii \" elif gc_color == self._gc_grey:\\n\"\n"
1536
+ ".ascii \" names.append('GC_GREY')\\n\"\n"
1537
+ ".ascii \" elif gc_color == self._gc_purple:\\n\"\n"
1538
+ ".ascii \" names.append('GC_PURPLE')\\n\"\n"
1542
1539
".ascii \"\\n\"\n"
1543
1540
".ascii \" gc_address = (flags >> self._info_shift) & self._gc_address\\n\"\n"
1544
1541
".ascii \" if gc_address != 0:\\n\"\n"
@@ -1577,17 +1574,16 @@ asm(
1577
1574
".ascii \" pattern = re.compile(r'#define (GC_[^\\\\s]+)\\\\s+((0x)\?[0-9a-f]+)')\\n\"\n"
1578
1575
".ascii \" matches = pattern.findall(content)\\n\"\n"
1579
1576
".ascii \" for name, bit, _ in matches:\\n\"\n"
1580
- ".ascii \" match name:\\n\"\n"
1581
- ".ascii \" case 'GC_TYPE_MASK':\\n\"\n"
1582
- ".ascii \" self._type_mask = int(bit, 0)\\n\"\n"
1583
- ".ascii \" case 'GC_FLAGS_MASK':\\n\"\n"
1584
- ".ascii \" self._flags_mask = int(bit, 0)\\n\"\n"
1585
- ".ascii \" case 'GC_INFO_MASK':\\n\"\n"
1586
- ".ascii \" self._info_mask = int(bit, 0)\\n\"\n"
1587
- ".ascii \" case 'GC_INFO_SHIFT':\\n\"\n"
1588
- ".ascii \" self._info_shift = int(bit, 0)\\n\"\n"
1589
- ".ascii \" case 'GC_FLAGS_SHIFT':\\n\"\n"
1590
- ".ascii \" self._flags_shift = int(bit, 0)\\n\"\n"
1577
+ ".ascii \" if name == 'GC_TYPE_MASK':\\n\"\n"
1578
+ ".ascii \" self._type_mask = int(bit, 0)\\n\"\n"
1579
+ ".ascii \" elif name == 'GC_FLAGS_MASK':\\n\"\n"
1580
+ ".ascii \" self._flags_mask = int(bit, 0)\\n\"\n"
1581
+ ".ascii \" elif name == 'GC_INFO_MASK':\\n\"\n"
1582
+ ".ascii \" self._info_mask = int(bit, 0)\\n\"\n"
1583
+ ".ascii \" elif name == 'GC_INFO_SHIFT':\\n\"\n"
1584
+ ".ascii \" self._info_shift = int(bit, 0)\\n\"\n"
1585
+ ".ascii \" elif name == 'GC_FLAGS_SHIFT':\\n\"\n"
1586
+ ".ascii \" self._flags_shift = int(bit, 0)\\n\"\n"
1591
1587
".ascii \"\\n\"\n"
1592
1588
".ascii \" # IS_STR_INTERNED GC_IMMUTABLE\\n\"\n"
1593
1589
".ascii \" # IS_STR_PERMANENT (1<<8)\\n\"\n"
@@ -1598,13 +1594,12 @@ asm(
1598
1594
".ascii \" bit = bits.get(val)\\n\"\n"
1599
1595
".ascii \" if bit == None:\\n\"\n"
1600
1596
".ascii \" continue\\n\"\n"
1601
- ".ascii \" match type:\\n\"\n"
1602
- ".ascii \" case 'STR':\\n\"\n"
1603
- ".ascii \" target = str_bits\\n\"\n"
1604
- ".ascii \" case 'ARRAY':\\n\"\n"
1605
- ".ascii \" target = array_bits\\n\"\n"
1606
- ".ascii \" case 'OBJ':\\n\"\n"
1607
- ".ascii \" target = obj_bits\\n\"\n"
1597
+ ".ascii \" if type == 'STR':\\n\"\n"
1598
+ ".ascii \" target = str_bits\\n\"\n"
1599
+ ".ascii \" elif type == 'ARRAY':\\n\"\n"
1600
+ ".ascii \" target = array_bits\\n\"\n"
1601
+ ".ascii \" elif type == 'OBJ':\\n\"\n"
1602
+ ".ascii \" target = obj_bits\\n\"\n"
1608
1603
".ascii \" target[name] = int(bit)\\n\"\n"
1609
1604
".ascii \"\\n\"\n"
1610
1605
".ascii \" # Hard coded because these are not exposed in header files\\n\"\n"
0 commit comments