Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
ast_transforms.cpython-313.pyc86 linesDownload Raw Back to __pycache__
1�

2��j���SSKJrJrJrJr SSKJr S\RS\R4SjrS\R\R-S\\RSS	4S3jrS\R\R-S\R\R-4SjrS\R\R-S\\R\R-\44S
jrg	)�)�Any�List�Tuple�cast�)�c_ast�switch_node�returnc��[U[R5(de[UR[R5(dU$[R"/URR45nSnURR=(d /H�n[U[R[R45(aAURRU5 [X1R5 URSnMsUcURRU5 M�URRU5 M� XlU$)a�The 'case' statements in a 'switch' come out of parsing with one5child node, so subsequent statements are just tucked to the parent6Compound. Additionally, consecutive (fall-through) case statements7come out messy. This is a peculiarity of the C grammar. The following:8 9    switch (myvar) {10        case 10:11            k = 10;12            p = k + 1;13            return 10;14        case 20:15        case 30:16            return 20;17        default:18            break;19    }20 21Creates this tree (pseudo-dump):22 23    Switch24        ID: myvar25        Compound:26            Case 10:27                k = 1028            p = k + 129            return 1030            Case 20:31                Case 30:32                    return 2033            Default:34                break35 36The goal of this transform is to fix this mess, turning it into the37following:38 39    Switch40        ID: myvar41        Compound:42            Case 10:43                k = 1044                p = k + 145                return 1046            Case 20:47            Case 30:48                return 2049            Default:50                break51 52A fixed AST node is returned. The argument may be modified.53N�����)�54isinstancer�Switch�stmt�Compound�coord�block_items�Case�Default�append�_extract_nested_case�stmts)r	�new_compound�	last_case�childs    �^D:\code\apps\devtools\python\user_packages\Python313\site-packages\pycparser/ast_transforms.py�fix_switch_casesrs��f�k�5�<�<�0�0�0�0��k�&�&����7�7����>�>�"�k�&6�&6�&<�&<�=�L�48�I�55�!�!�-�-�3��3���e�e�j�j�%�-�-�8�9�9�56
�$�$�+�+�E�2� ��(@�(@�A�$�0�0��4�I�� ��(�(�/�/��6����&�&�u�-�4�"$�����	case_node�57stmts_listNc��[URS[R[R45(aFURR5nUR
U5 [[[U5U5 gg)zsRecursively extract consecutive Case statements that are made nested58by the parser and add them to the stmts_list.59rN)60r
rrrr�poprrrr)rr�nesteds   rrres^���)�/�/�!�$�u�z�z�5�=�=�&A�B�B����$�$�&�����&�!��T�#�v�.�61�;�Cr�declc��[U5upU(dOMUn[U[R5(d.URn[U[R5(dM.SUR;a+SUR;aURRS5 URcURUlU$![62a Us$f=f)a&Atomic specifiers like _Atomic(type) are unusually structured,63conferring a qualifier upon the contained type.64 65This function fixes a decl with atomic specifiers to have a sane AST66structure, by removing spurious Typename->TypeDecl pairs and attaching67the _Atomic qualifier in the right place.68�_Atomic)69�_fix_atomic_specifiers_oncer
r�TypeDecl�type�AttributeError�qualsr�declname�name)r#�found�typs   r�fix_atomic_specifiersr/qs����1�$�7�������C���e�n�n�-�-�	��(�(�C���e�n�n�-�-�70�C�I�I��)�4�:�:�"=��71�72���)�$�73�|�|���y�y����K���	��K�	�s�C�C�Cc���UnSnURnUbF[U[R5(aSUR;aOUnUnURnUbMF[U[R5(deUceUR[[U5lSURR;a%URRRS5 US4$![74a US4s$f=f)zvPerforms one 'fix' round of atomic specifiers.75Returns (modified_decl, found) where found is True iff a fix was made.76Nr%FT)77r(r
r�Typenamer*r)r'rrr)r#�parent�grandparent�nodes    rr&r&�s����F��K��	�	�D�78�79��d�E�N�N�+�+�	�T�Z�Z�0G��	� �K��F��9�9�D�
�80��f�e�n�n�-�-�-�-��"�"�"�"&�)�)�D��k�����	�	���'��	�	�����y�)���:����	���;��		�s�C"�"C3�2C3)�typingrrrr�rrrrr�Noder�Decl�Typedefr/�boolr&�rr�<module>r<s���*�)��S�%�,�,�S�5�<�<�S�l	<��z�z�E�M�M�)�	<�7;�E�J�J�7G�	<�	�	<��81�*�*�u�}�}�82$��83�Z�Z�%�-�-���D�84�*�*�u�}�}�85$��86�5�:�:��
�
�%�t�+�,�r
codekingpro/portable-devtools · Team Ai