Ë
    7^(hì”  ã                   óp  — d dl mZ d dlZ edddgi¬«      Z	 er�d dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZmZm Z m!Z! d d	l"m#Z#m$Z$m%Z%m&Z&m'Z' d d
l(m)Z)m*Z*m+Z+m,Z, d dl-m.Z. d dl/m0Z0 d dl(m1Z1m2Z2 d dl3Z3d dl4Z4 G d„ d«      Z5 G d„ de5«      Z6d„ Z7y G d„ d«      Z6d„ Z7y)é    )Úimport_moduleNzclang.cindexÚfromlistÚcindex)Úimport_kwargs)ÚVariableÚIntegerÚFloatÚFunctionPrototypeÚFunctionDefinitionÚFunctionCallÚnoneÚReturnÚ
AssignmentÚintcÚint8Úint16Úint64Úuint8Úuint16Úuint32Úuint64Úfloat32Úfloat64Úfloat80Ú
aug_assignÚbool_ÚWhileÚ	CodeBlock)ÚPreDecrementÚPostDecrementÚPreIncrementÚPostIncrement)ÚAddÚModÚMulÚPowÚRel)ÚAndÚ
as_BooleanÚNotÚOr)ÚSymbol)Úsympify)ÚfalseÚtruec                   ó   — e Zd ZdZd„ Zd„ Zy)Ú
BaseParserzBase Class for the C parserc                 óJ   — t         j                  j                  «       | _        y)z6Initializes the Base parser creating a Clang AST indexN)ÚcinÚIndexÚcreateÚindex)Úselfs    úV/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/parsing/c/c_parser.pyÚ__init__zBaseParser.__init__?   s   € äŸ™×)Ñ)Ó+ˆD�Jó    c                 ó"  — | j                   j                  D ]v  }t        ddddddœ|j                     ›d|j                  j
                  ›d|j                  j                  ›d	|j                  j                  ›d
|j                  ›�	|¬«       Œx y)z%Diagostics function for the Clang ASTÚFATALÚERRORÚWARNINGÚNOTEÚIGNORED)é   é   é   é   r   ú z (line z, col z) ©ÚfileN)	ÚtuÚdiagnosticsÚprintÚseverityÚlocationrG   ÚlineÚcolumnÚspelling)r7   ÚoutÚdiags      r8   rI   zBaseParser.diagnosticsC   s   € àŸ™×+Ñ+ò !�äà&Ø&Ø(Ø%Ø(ñð Ÿ-™-ó)ð Ÿ™×*Ó*ØŸ™×*Ó*ØŸ™×,Ó,ØŸšðð  ö!ñ!r:   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r9   rI   © r:   r8   r1   r1   <   s   „ Ù)ò	,ó	!r:   r1   c                   óÄ   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zˆ xZ S )ÚCCodeConverterz¡The Code Convereter for Clang AST

        The converter object takes the C source code or file as input and
        converts them to SymPy Expressions.
        c                 óT  •— t         ‰| �  «        g | _        t        j                  j
                  t        it        j                  j                  t        it        j                  j                  t        t        j                  j                  t        t        j                  j                  t        t        j                  j                  t         t        j                  j"                  t$        t        j                  j&                  t(        t        j                  j*                  t,        t        j                  j.                  t0        it        j                  j2                  t4        t        j                  j6                  t8        t        j                  j:                  t<        idœ| _        y)zInitializes the code converter)ÚvoidÚboolÚintÚfloatN) Úsuperr9   Ú	_py_nodesr3   ÚTypeKindÚVOIDr   ÚBOOLr   ÚSCHARr   ÚSHORTr   ÚINTr   ÚLONGr   ÚUCHARr   ÚUSHORTr   ÚUINTr   ÚULONGr   ÚFLOATr   ÚDOUBLEr   Ú
LONGDOUBLEr   Ú_data_types)r7   Ú	__class__s    €r8   r9   zCCodeConverter.__init__\   sþ   ø€ ä‰GÑÔØˆDŒNô —L‘L×%Ñ%¤tðô —L‘L×%Ñ%¤uðô —L‘L×&Ñ&¬Ü—L‘L×&Ñ&¬Ü—L‘L×$Ñ$¤dÜ—L‘L×%Ñ%¤uÜ—L‘L×&Ñ&¬Ü—L‘L×'Ñ'¬Ü—L‘L×%Ñ%¤vÜ—L‘L×&Ñ&¬ð	ô —L‘L×&Ñ&¬Ü—L‘L×'Ñ'¬Ü—L‘L×+Ñ+¬Wðñ# ˆDÕr:   c                 ó  — t         j                  j                  |«      }| j                  j	                  ||t
        j                  j                  ¬«      | _        | j                  j                  j                  «       D ]{  }|j                  t
        j                  j                  k(  s(|j                  t
        j                  j                  k(  sŒR| j                  j!                  | j#                  |«      «       Œ} | j                  S )aµ  Function to parse a file with C source code

            It takes the filename as an attribute and creates a Clang AST
            Translation Unit parsing the file.
            Then the transformation function is called on the translation unit,
            whose results are collected into a list which is returned by the
            function.

            Parameters
            ==========

            filename : string
                Path to the C file to be parsed

            flags: list
                Arguments to be passed to Clang while parsing the C code

            Returns
            =======

            py_nodes: list
                A list of SymPy AST nodes

            ©ÚargsÚoptions)ÚosÚpathÚabspathr6   Úparser3   ÚTranslationUnitÚ PARSE_DETAILED_PROCESSING_RECORDrH   ÚcursorÚget_childrenÚkindÚ
CursorKindÚVAR_DECLÚFUNCTION_DECLr_   ÚappendÚ	transform)r7   ÚfilenameÚflagsÚfilepathÚchilds        r8   rw   zCCodeConverter.parsex   s¼   € ô2 —w‘w—‘ xÓ0ˆHØ—j‘j×&Ñ&ØØÜ×+Ñ+×LÑLð 'ó ˆDŒGð
 Ÿ™Ÿ™×4Ñ4Ó6ò A�Ø—:‘:¤§¡×!8Ñ!8Ò8¸E¿J¹JÌ#Ï.É.×JfÑJfÓ<fØ—N‘N×)Ñ)¨$¯.©.¸Ó*?Õ@ðAð —>‘>Ð!r:   c                 óš  — t        j                  dd¬«      }|j                  |«       |j                  «        |j	                  d«       | j
                  j                  |j                  |t        j                  j                  ¬«      | _        |j                  «        | j                  j                  j                  «       D ]{  }|j                  t        j                   j"                  k(  s(|j                  t        j                   j$                  k(  sŒR| j&                  j)                  | j+                  |«      «       Œ} | j&                  S )aê  Function to parse a string with C source code

            It takes the source code as an attribute, stores it in a temporary
            file and creates a Clang AST Translation Unit parsing the file.
            Then the transformation function is called on the translation unit,
            whose results are collected into a list which is returned by the
            function.

            Parameters
            ==========

            source : string
                A string containing the C source code to be parsed

            flags: list
                Arguments to be passed to Clang while parsing the C code

            Returns
            =======

            py_nodes: list
                A list of SymPy AST nodes

            zw+z.cpp)ÚmodeÚsuffixr   rq   )ÚtempfileÚNamedTemporaryFileÚwriteÚflushÚseekr6   rw   Únamer3   rx   ry   rH   Úcloserz   r{   r|   r}   r~   r   r_   r€   r�   )r7   Úsourcerƒ   rG   r…   s        r8   Ú	parse_strzCCodeConverter.parse_strœ   sé   € ô2 ×.Ñ.°dÀVÔLˆDØ�J‰J�vÔØ�J‰JŒLØ�I‰I�aŒLØ—j‘j×&Ñ&Ø—	‘	ØÜ×+Ñ+×LÑLð 'ó ˆDŒGð
 �J‰JŒLØŸ™Ÿ™×4Ñ4Ó6ò A�Ø—:‘:¤§¡×!8Ñ!8Ò8¸E¿J¹JÌ#Ï.É.×JfÑJfÓ<fØ—N‘N×)Ñ)¨$¯.©.¸Ó*?Õ@ðAð —>‘>Ð!r:   c           
      ó  — t        | d|j                  j                  j                  «       z  d«      }|€Pt	        d|j                  ›ddj                  d„ |j                  «       D «       «      ›d�t        j                  ¬«        ||«      S )	aF  Transformation Function for Clang AST nodes

            It determines the kind of node and calls the respective
            transformation function for that node.

            Raises
            ======

            NotImplementedError : if the transformation for the provided node
            is not implemented

            ztransform_%sNzIgnoring node of type z (rE   c              3   ó4   K  — | ]  }|j                   –— Œ y ­w©N©rO   ©Ú.0Úts     r8   ú	<genexpr>z+CCodeConverter.transform.<locals>.<genexpr>×   s   è ø€ ò !CØ+,˜AŸJ�Jñ!Cùó   ‚ú)rF   )	Úgetattrr|   rŽ   ÚlowerrJ   ÚjoinÚ
get_tokensÚsysÚstderr)r7   ÚnodeÚhandlers      r8   r�   zCCodeConverter.transformÄ   sy   € ô ˜d N°T·Y±Y·^±^×5IÑ5IÓ5KÑ$KÈTÓRˆGàˆÝàŸ	›	ØŸ™ñ !CØ04·±Ó0Aô!Cõ Cðô
 Ÿ™õñ ˜4“=Ð r:   c           	      ó
  — |j                   j                  | j                  d   v r'| j                  d   |j                   j                     }n£|j                   j                  | j                  d   v r'| j                  d   |j                   j                     }nW|j                   j                  | j                  d   v r'| j                  d   |j                   j                     }nt        d«      ‚	 |j	                  «       }t        |«      }|j                  t        j                  j                  k(  s'|j                  t        j                  j                  k(  r[t        |«      }|j                  t        j                  j                  k(  rŒ3|j                  t        j                  j                  k(  rŒ[| j                  |«      }t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                  t        j                  j                   t        j                  j"                  g}|j                  |v �rÅt%        |t&        «      rt)        |«      }�n‚t%        |t*        «      r´|j                   j                  | j                  d   v r|dk(  rt-        d«      n
t-        d«      }�n0|j                   j                  | j                  d   v r|dk(  rt/        d«      n
t/        d	«      }nï|j                   j                  | j                  d   v rÊt1        |«      }n¾t%        |t,        t2        t.        t4        f«      rœ|j                   j                  | j                  d   v rt-        |«      }nm|j                   j                  | j                  d   v rt/        |«      }n<|j                   j                  | j                  d   v rt1        t+        |«      «      }n|}t7        |j8                  «      j;                  |¬
«      S |j                  t        j                  j<                  k(  r%t7        |j8                  «      j;                  |¬«      S t        dj?                  djA                  d„ |jC                  «       D «       «      «      «      ‚# tD        $ r( t7        |j8                  «      j;                  |¬«      cY S w xY w)a‘  Transformation Function for Variable Declaration

            Used to create nodes for variable declarations and assignments with
            values or function call for the respective nodes in the clang AST

            Returns
            =======

            A variable node as Declaration, with the initial value if given

            Raises
            ======

            NotImplementedError : if called for data types not currently
            implemented

            Notes
            =====

            The function currently supports following data types:

            Boolean:
                bool, _Bool

            Integer:
                8-bit: signed char and unsigned char
                16-bit: short, short int, signed short,
                    signed short int, unsigned short, unsigned short int
                32-bit: int, signed int, unsigned int
                64-bit: long, long int, signed long,
                    signed long int, unsigned long, unsigned long int

            Floating point:
                Single Precision: float
                Double Precision: double
                Extended Precision: long double

            r\   r]   r[   ú&Only bool, int and float are supportedFr   rD   g        g      ð?©ÚtypeÚvalue)r¨   z=Given variable declaration "{}" is not possible to parse yet!rE   c              3   ó4   K  — | ]  }|j                   –— Œ y ­wr”   r•   r–   s     r8   r™   z4CCodeConverter.transform_var_decl.<locals>.<genexpr>I  s   è ø€ ò )Ø+,˜AŸJ�Jñ)ùrš   ©r§   )#r§   r|   rn   ÚNotImplementedErrorr{   Únextr3   r}   ÚNAMESPACE_REFÚTYPE_REFr�   ÚINTEGER_LITERALÚFLOATING_LITERALÚUNEXPOSED_EXPRÚBINARY_OPERATORÚ
PAREN_EXPRÚUNARY_OPERATORÚCXX_BOOL_LITERAL_EXPRÚ
isinstanceÚstrr,   r[   r   r	   r-   r\   r]   r   rO   Úas_DeclarationÚ	CALL_EXPRÚformatrž   rŸ   ÚStopIteration)r7   r¢   r§   Úchildrenr…   ÚvalÚsupported_rhsr¨   s           r8   Útransform_var_declz!CCodeConverter.transform_var_declß   sÎ  € ðN �y‰y�~‰~ ×!1Ñ!1°%Ñ!8Ñ8Ø×'Ñ'¨Ñ.¨t¯y©y¯~©~Ñ>‘Ø—‘—‘ 4×#3Ñ#3°GÑ#<Ñ<Ø×'Ñ'¨Ñ0°·±·±Ñ@‘Ø—‘—‘ 4×#3Ñ#3°FÑ#;Ñ;Ø×'Ñ'¨Ñ/°·	±	·±Ñ?‘ä)ð +.ó /ð /ðDØ×,Ñ,Ó.�Ü˜X›�ð —j‘j¤C§N¡N×$@Ñ$@Ò@ÀEÇJÁJÔRU×R`ÑR`×RiÑRiÒDiÜ  ›N�Eð —j‘j¤C§N¡N×$@Ñ$@Ó@ÀEÇJÁJÔRU×R`ÑR`×RiÑRiÓDið —n‘n UÓ+�ô —N‘N×2Ñ2Ü—N‘N×3Ñ3Ü—N‘N×1Ñ1Ü—N‘N×2Ñ2Ü—N‘N×-Ñ-Ü—N‘N×1Ñ1Ü—N‘N×8Ñ8ð!�ð —:‘: Ò.Ü! #¤sÔ+Ü & s£šÜ# C¬Ô.ØŸ9™9Ÿ>™>¨T×-=Ñ-=¸eÑ-DÑDØ25¸²,¤G¨A¤JÄGÈAÃJšEØ!ŸY™YŸ^™^¨t×/?Ñ/?ÀÑ/HÑHØ25¸²,¤E¨#¤JÄEÈ#ÃJ™EØ!ŸY™YŸ^™^¨t×/?Ñ/?ÀÑ/GÑGÜ$+¨C£L™EÜ# C¬'´3¼¼uÐ)EÔFØŸ9™9Ÿ>™>¨T×-=Ñ-=¸eÑ-DÑDÜ$+¨C£L™EØ!ŸY™YŸ^™^¨t×/?Ñ/?ÀÑ/HÑHÜ$)¨#£J™EØ!ŸY™YŸ^™^¨t×/?Ñ/?ÀÑ/GÑGÜ$+¬D°«IÓ$6™Eà #˜ä#Ø—M‘Móç$‘nØ#Ø %ð %ó ðð —Z‘Z¤3§>¡>×#;Ñ#;Ò;Ü#ØŸ™óç(™.Ø$'ð )ó ðô .ð /8÷  ™ §¡ñ )Ø04·±Ó0Aô)ó !ó óð øô !ò ÜØ—‘óç ‘.Øð !ó òðús-   Ã1BS Æ'S Æ5JS ÑAS Ò>S Ó.TÔTc                 óT  — |j                   j                  | j                  d   v r'| j                  d   |j                   j                     }nï|j                   j                  | j                  d   v r'| j                  d   |j                   j                     }n£|j                   j                  | j                  d   v r'| j                  d   |j                   j                     }nW|j                   j                  | j                  d   v r'| j                  d   |j                   j                     }nt        d«      ‚g }g }|j	                  «       D ]�  }| j                  |«      }|j                  t        j                  j                  k(  r|j                  |«       ŒM|j                  t        j                  j                  k(  r|D ]  }|j                  |«       Œ Œ�|j                  |«       ŒŸ |g k(  rt        ||j                  |¬«      }|S t        ||j                  ||¬«      }|S )a¦  Transformation Function For Function Declaration

            Used to create nodes for function declarations and definitions for
            the respective nodes in the clang AST

            Returns
            =======

            function : Codegen AST node
                - FunctionPrototype node if function body is not present
                - FunctionDefinition node if the function body is present


            r\   r]   r[   rZ   z,Only void, bool, int and float are supported)Úreturn_typerŽ   Ú
parameters)rÁ   rŽ   rÂ   Úbody)Úresult_typer|   rn   r«   r{   r�   r3   r}   Ú	PARM_DECLr€   ÚCOMPOUND_STMTr
   rO   r   )	r7   r¢   Úret_typerÃ   Úparamr…   Údeclr½   Úfunctions	            r8   Útransform_function_declz&CCodeConverter.transform_function_declU  só  € ð  ×Ñ×$Ñ$¨×(8Ñ(8¸Ñ(?Ñ?Ø×+Ñ+¨EÑ2°4×3CÑ3C×3HÑ3HÑI‘Ø×!Ñ!×&Ñ&¨$×*:Ñ*:¸7Ñ*CÑCØ×+Ñ+¨GÑ4°T×5EÑ5E×5JÑ5JÑK‘Ø×!Ñ!×&Ñ&¨$×*:Ñ*:¸6Ñ*BÑBØ×+Ñ+¨FÑ3°D×4DÑ4D×4IÑ4IÑJ‘Ø×!Ñ!×&Ñ&¨$×*:Ñ*:¸6Ñ*BÑBØ×+Ñ+¨FÑ3°D×4DÑ4D×4IÑ4IÑJ‘ä)ð +.ó /ð /àˆDØˆEð ×*Ñ*Ó,ò &�Ø—~‘~ eÓ,�Ø—:‘:¤§¡×!9Ñ!9Ò9Ø—L‘L Õ&Ø—Z‘Z¤3§>¡>×#?Ñ#?Ò?Ø#ò )˜ØŸ™ CÕ(ñ)ð —K‘K Õ%ð&ð �rŠzÜ,Ø"*ØŸ=™=Ø!&ô�ð ˆOô .Ø"*ØŸ=™=Ø!&Øô	�ð ˆOr:   c                 ó$  — |j                   j                  | j                  d   v r'| j                  d   |j                   j                     }n£|j                   j                  | j                  d   v r'| j                  d   |j                   j                     }nW|j                   j                  | j                  d   v r'| j                  d   |j                   j                     }nt        d«      ‚	 |j	                  «       }t        |«      }|j                  t        j                  j                  t        j                  j                  t        j                  j                  fv ret        |«      }|j                  t        j                  j                  t        j                  j                  t        j                  j                  fv rŒe| j                  |«      }|j                   j                  | j                  d   v rt        |«      }nv|j                   j                  | j                  d   v rt        |«      }nE|j                   j                  | j                  d   v rt        t        |«      «      }nt        d«      ‚t!        |j"                  «      j%                  ||¬«      }	 | j                  t        «      «       t)        d«      ‚# t&        $ r( t!        |j"                  «      j%                  |¬«      }Y ŒVw xY w# t&        $ r Y |S w xY w)aÇ  Transformation function for Parameter Declaration

            Used to create parameter nodes for the required functions for the
            respective nodes in the clang AST

            Returns
            =======

            param : Codegen AST Node
                Variable node with the value and type of the variable

            Raises
            ======

            ValueError if multiple children encountered in the parameter node

            r\   r]   r[   r¥   r¦   rª   z+Can't handle multiple children on parameter)r§   r|   rn   r«   r{   r¬   r3   r}   r­   r®   ÚTEMPLATE_REFr�   r   r	   r-   r[   r   rO   r¸   r»   Ú
ValueError)r7   r¢   r§   r¼   r…   Úlitr½   rÈ   s           r8   Útransform_parm_declz"CCodeConverter.transform_parm_decl�  s‰  € ð$ �y‰y�~‰~ ×!1Ñ!1°%Ñ!8Ñ8Ø×'Ñ'¨Ñ.¨t¯y©y¯~©~Ñ>‘Ø—‘—‘ 4×#3Ñ#3°GÑ#<Ñ<Ø×'Ñ'¨Ñ0°·±·±Ñ@‘Ø—‘—‘ 4×#3Ñ#3°FÑ#;Ñ;Ø×'Ñ'¨Ñ/°·	±	·±Ñ?‘ä)ð +.ó /ð /ð!Ø×,Ñ,Ó.�Ü˜X›�ð —j‘j¤S§^¡^×%AÑ%AÜ%(§^¡^×%<Ñ%<Ü%(§^¡^×%@Ñ%@ð%Bñ Bô ! ›N�Eð —j‘j¤S§^¡^×%AÑ%AÜ%(§^¡^×%<Ñ%<Ü%(§^¡^×%@Ñ%@ð%Bò Bð —n‘n UÓ+�Ø—9‘9—>‘> T×%5Ñ%5°eÑ%<Ñ<Ü! #›,‘CØ—Y‘Y—^‘^ t×'7Ñ'7¸Ñ'@Ñ@Ü ›*‘CØ—Y‘Y—^‘^ t×'7Ñ'7¸Ñ'?Ñ?Ü!¤$ s£)Ó,‘Cä-ð /2ó 3ð 3ô !Ø—M‘Móç ‘.ØØð !ó ð ðØ—‘œt H›~Ô.Ü Ð!NÓOÐOøô !ò Ü Ø—M‘Móç ‘.Øð !ó ò ðûô !ò ØàˆLðús,   Ã1CK Ç
CK Ê)%L Ë.K?Ë>K?Ì	LÌLc                 óª   — 	 t        |j                  «       «      j                  }t        |«      S # t        $ r |j                  }Y t        |«      S w xY w)aÌ  Transformation function for integer literal

            Used to get the value and type of the given integer literal.

            Returns
            =======

            val : list
                List with two arguments type and Value
                type contains the type of the integer
                value contains the value stored in the variable

            Notes
            =====

            Only Base Integer type supported for now

            )r¬   rŸ   rO   r»   Úliteralr\   ©r7   r¢   r¨   s      r8   Útransform_integer_literalz(CCodeConverter.transform_integer_literalÓ  sN   € ð&%Ü˜TŸ_™_Ó.Ó/×8Ñ8�ô �u“:Ðøô !ò %àŸ™‘Ü�u“:Ðð%ús   ‚#0 °AÁAc                 ó¶   — 	 t        |j                  «       «      j                  }t        |«      S # t        t        f$ r |j
                  }Y t        |«      S w xY w)aÆ  Transformation function for floating literal

            Used to get the value and type of the given floating literal.

            Returns
            =======

            val : list
                List with two arguments type and Value
                type contains the type of float
                value contains the value stored in the variable

            Notes
            =====

            Only Base Float type supported for now

            )r¬   rŸ   rO   r»   rÎ   rÒ   r]   rÓ   s      r8   Útransform_floating_literalz)CCodeConverter.transform_floating_literalí  sS   € ð&%Ü˜TŸ_™_Ó.Ó/×8Ñ8�ô ˜“<Ðøô "¤:Ð.ò %àŸ™‘Ü˜“<Ðð%ús   ‚#0 °AÁAc                  ó   — y r”   rV   ©r7   r¢   s     r8   Útransform_string_literalz'CCodeConverter.transform_string_literal  s   € ð r:   c                 óº   — 	 t        |j                  «       «      j                  }t        t        |d   «      «      S # t        t        f$ r |j
                  }Y Œ4w xY w)a­  Transformation function for character literal

            Used to get the value of the given character literal.

            Returns
            =======

            val : int
                val contains the ascii value of the character literal

            Notes
            =====

            Only for cases where character is assigned to a integer value,
            since character literal is not in SymPy AST

            rD   )r¬   rŸ   rO   r»   rÎ   rÒ   Úordr·   rÓ   s      r8   Útransform_character_literalz*CCodeConverter.transform_character_literal  sR   € ð$%Ü˜TŸ_™_Ó.Ó/×8Ñ8�ô ”s˜5 ™8“}Ó%Ð%øô "¤:Ð.ò %àŸ™’ð%ús   ‚#< ¼AÁAc                 óž   — 	 t        |j                  «       «      j                  }|dk(  rdS dS # t        t        f$ r |j
                  }Y Œ&w xY w)zþTransformation function for boolean literal

            Used to get the value of the given boolean literal.

            Returns
            =======

            value : bool
                value contains the boolean value of the variable

            r/   TF)r¬   rŸ   rO   r»   rÎ   rÒ   rÓ   s      r8   Útransform_cxx_bool_literal_exprz.CCodeConverter.transform_cxx_bool_literal_expr,  sP   € ð%Ü˜TŸ_™_Ó.Ó/×8Ñ8�ð ! Fš?�4Ð5°Ð5øô "¤:Ð.ò %ØŸ™’ð%ús   ‚#. ®AÁAc                  ó   — y)z2Transformation function for unexposed declarationsNrV   rØ   s     r8   Útransform_unexposed_declz'CCodeConverter.transform_unexposed_decl>  s   € àr:   c                 óÄ   — 	 |j                  «       }| j                  t        |«      «      }	 t        |«       t	        d«      ‚# t        $ r Y yw xY w# t        $ r Y |S w xY w)aæ  Transformation function for unexposed expression

            Unexposed expressions are used to wrap float, double literals and
            expressions

            Returns
            =======

            expr : Codegen AST Node
                the result from the wrapped expression

            None : NoneType
                No children are found for the node

            Raises
            ======

            ValueError if the expression contains multiple children

            Nz&Unexposed expression has > 1 children.©r{   r�   r¬   r»   rÎ   )r7   r¢   r¼   Úexprs       r8   Útransform_unexposed_exprz'CCodeConverter.transform_unexposed_exprB  sk   € ð.Ø×,Ñ,Ó.�Ø—~‘~¤d¨8£nÓ5�ðÜ�X”Ü Ð!IÓJÐJøô !ò Ùðûô !ò ØàˆKðús"   ‚*A ­A Á	AÁAÁ	AÁAc                 ó   — |j                   S )z-Returns the name of the declaration referencer•   rØ   s     r8   Útransform_decl_ref_exprz&CCodeConverter.transform_decl_ref_exprg  s   € à—=‘=Ð r:   c                 ón  — g }|j                  «       }t        |«      }|j                  t        j                  j
                  k(  r3t        |«      }|j                  t        j                  j
                  k(  rŒ3|j                  t        j                  j                  k(  r3t        |«      }|j                  t        j                  j                  k(  rŒ3| j                  |«      }	 |D ]¨  }| j                  |«      }|j                  t        j                  j                  k(  r|j                  t        |«      «       ŒV|j                  t        j                  j                  k(  r|j                  t        |«      «       Œ˜|j                  |«       Œª t        ||«      S # t        $ r t        |«      cY S w xY w)aJ  Transformation function for a call expression

            Used to create function call nodes for the function calls present
            in the C code

            Returns
            =======

            FunctionCall : Codegen AST Node
                FunctionCall node with parameters if any parameters are present

            )r{   r¬   r|   r3   r}   r­   r®   r�   r¯   r€   r   r°   r	   r   r»   )r7   r¢   rÈ   r¼   r…   Úfirst_childÚargs          r8   Útransform_call_exprz"CCodeConverter.transform_call_exprk  sA  € ð ˆEØ×(Ñ(Ó*ˆHÜ˜“NˆEà—*‘*¤§¡× <Ñ <Ò<Ü˜X›�ð —*‘*¤§¡× <Ñ <Ó<à—*‘*¤§¡× 7Ñ 7Ò7Ü˜X›�ð —*‘*¤§¡× 7Ñ 7Ó7ð Ÿ.™.¨Ó/ˆKð1Ø%ò *�EØŸ.™.¨Ó/�CØ—z‘z¤S§^¡^×%CÑ%CÒCØŸ™¤W¨S£\Õ2ØŸ™¤s§~¡~×'FÑ'FÒFØŸ™¤U¨3£ZÕ0àŸ™ SÕ)ð*ô $ K°Ó7Ð7øä ò 1Ü# KÓ0Ò0ð1ús   Ã$B8F ÆF4Æ3F4c                 óZ   — t        t        |j                  «       «      j                  «      S )z.Returns the Return Node for a return statement)r   r¬   r{   rO   rØ   s     r8   Útransform_return_stmtz$CCodeConverter.transform_return_stmt�  s!   € äœ$˜t×0Ñ0Ó2Ó3×<Ñ<Ó=Ð=r:   c                 óx   — g }|j                  «       }|D ]"  }|j                  | j                  |«      «       Œ$ |S )a  Transformation function for compound statements

            Returns
            =======

            expr : list
                list of Nodes for the expressions present in the statement

            None : NoneType
                if the compound statement is empty

            )r{   r€   r�   )r7   r¢   rã   r¼   r…   s        r8   Útransform_compound_stmtz&CCodeConverter.transform_compound_stmt”  s@   € ð ˆDØ×(Ñ(Ó*ˆHà!ò 3�Ø—‘˜DŸN™N¨5Ó1Õ2ð3àˆKr:   c                 óâ   — 	 |j                  «       }| j                  t        |«      «      }	 | j                  t        «      «       t	        d«      ‚# t        $ r Y Œ1w xY w# t        $ r Y S w xY w)a@  Transformation function for declaration statements

            These statements are used to wrap different kinds of declararions
            like variable or function declaration
            The function calls the transformer function for the child of the
            given node

            Returns
            =======

            statement : Codegen AST Node
                contains the node returned by the children node for the type of
                declaration

            Raises
            ======

            ValueError if multiple children present

            z,Don't know how to handle multiple statementsrâ   )r7   r¢   r¼   Ú	statements       r8   Útransform_decl_stmtz"CCodeConverter.transform_decl_stmt¨  su   € ð*Ø×,Ñ,Ó.�Ø ŸN™N¬4°«>Ó:�	ðØ—‘œt H›~Ô.Ü Ð!OÓPÐPøô !ò Ùðûô !ò ØàÐðús"   ‚*A ­%A! Á	AÁAÁ!	A.Á-A.c                 óR   — | j                  t        |j                  «       «      «      S )z{Transformation function for Parenthesized expressions

            Returns the result from its children nodes

            )r�   r¬   r{   rØ   s     r8   Útransform_paren_exprz#CCodeConverter.transform_paren_exprË  s!   € ð —>‘>¤$ t×'8Ñ'8Ó':Ó";Ó<Ð<r:   c                 ó$   — | j                  |«      S )a¿  Transformation function for handling shorthand operators

            Returns
            =======

            augmented_assignment_expression: Codegen AST node
                    shorthand assignment expression represented as Codegen AST

            Raises
            ======

            NotImplementedError
                If the shorthand operator for bitwise operators
                (~=, ^=, &=, |=, <<=, >>=) is encountered

            )Útransform_binary_operatorrØ   s     r8   Ú&transform_compound_assignment_operatorz5CCodeConverter.transform_compound_assignment_operatorÓ  s   € ð" ×1Ñ1°$Ó7Ð7r:   c                 ó$  — g d¢}t        |j                  «       «      }|d   j                  |v �rQ| j                  t	        |j                  «       «      «      }t        |t        «      r¶|d   j                  dk(  rt        |«      S |d   j                  dk(  rt        t        |«      d«      S |d   j                  dk(  rt        t        |«      «      S |d   j                  dk(  rt        t        |«      «      S |d   j                  dk(  rvt        t        |«      «      S |d   j                  dk(  r|S |d   j                  dk(  rt        |d«      S |d   j                  dk(  rt        t        t        |«      «      «      S yy|d	   j                  d
v ru| j                  t	        |j                  «       «      «      }|d	   j                  dk(  rt        t        |«      «      S |d	   j                  dk(  rt!        t        |«      «      S yt#        d«      ‚)aª  Transformation function for handling unary operators

            Returns
            =======

            unary_expression: Codegen AST node
                    simplified unary expression represented as Codegen AST

            Raises
            ======

            NotImplementedError
                If dereferencing operator(*), address operator(&) or
                bitwise NOT operator(~) is encountered

            )ú+ú-ú++ú--ú!r   rø   rù   éÿÿÿÿrú   rû   rü   rD   )rú   rû   z`Dereferencing operator, Address operator and bitwise NOT operator have not been implemented yet!N)ÚlistrŸ   rO   r�   r¬   r{   r¶   r·   r,   r%   r!   r   r*   r-   r[   r"   r    r«   )r7   r¢   Úoperators_listÚtokensr…   s        r8   Útransform_unary_operatorz'CCodeConverter.transform_unary_operatoræ  sè  € ò$ 9ˆNÜ˜$Ÿ/™/Ó+Ó,ˆFð �a‰y×!Ñ! ^Ò3ØŸ™¤t¨D×,=Ñ,=Ó,?Ó'@ÓA�ä˜e¤SÔ)Ø˜a‘y×)Ñ)¨SÒ0Ü% e›}Ð,Ø˜a‘y×)Ñ)¨SÒ0Ü"¤6¨%£=°"Ó5Ð5Ø˜a‘y×)Ñ)¨TÒ1Ü+¬F°5«MÓ:Ð:Ø˜a‘y×)Ñ)¨TÒ1Ü+¬F°5«MÓ:Ð:Ø˜a‘y×)Ñ)¨SÒ0Ü"¤6¨%£=Ó1Ð1ð ˜a‘y×)Ñ)¨SÒ0Ø$˜Ø˜a‘y×)Ñ)¨SÒ0Ü" 5¨"›~Ð-Ø˜a‘y×)Ñ)¨SÒ0Ü"¤7¬4°«;Ó#7Ó8Ð8ð 1ð 1ð ˜‘×#Ñ# |Ñ3ØŸ™¤t¨D×,=Ñ,=Ó,?Ó'@ÓA�Ø˜!‘9×%Ñ%¨Ò-Ü(¬°«Ó7Ð7Ø˜!‘9×%Ñ%¨Ò-Ü(¬°«Ó7Ð7ð .ô *ð +5ó 6ð 6r:   c                 ó¾  — t        |j                  «       «      }g d¢}g }g }|D �]?  }|j                  t        j                  j
                  k(  �r|j                  dk(  r|j                  d«       ŒM|j                  dk(  r‘|r~|d   dk7  rvt        |«      dk  rt        d«      ‚|j                  «       }|j                  «       }|j                  «       }	|j                  | j                  |||	«      «       |r	|d   dk7  rŒv|j                  «        Œí|j                  |v rí|rÎ| j                  |j                  «      | j                  |d   «      k  ržt        |«      dk  rt        d«      ‚|j                  «       }|j                  «       }|j                  «       }	|j                  | j                  |||	«      «       |r1| j                  |j                  «      | j                  |d   «      k  rŒž|j                  |j                  «       �Œè|j                  dv rt        d«      ‚|j                  d	v rt        d
«      ‚t        dj                  |j                  «      «      ‚|j                  t        j                  j                  k(  r|j                  |j                  dg«       �Œ„|j                  t        j                  j                  k(  r|j                  |j                  dg«       �ŒÊ|j                  t        j                  j                   k(  r-|j                  dv r|j                  |j                  dg«       �Œt        dj                  |j                  «      «      ‚ |rnt        |«      dk  rt        d«      ‚|j                  «       }|j                  «       }|j                  «       }	|j                  | j                  |||	«      «       |rŒn|d   d   S )aÎ  Transformation function for handling binary operators

            Returns
            =======

            binary_expression: Codegen AST node
                    simplified binary expression represented as Codegen AST

            Raises
            ======

            NotImplementedError
                If a bitwise operator or
                unary operator(which is a child of any binary
                operator in Clang AST) is encountered

            )rø   rù   Ú*ú/ú%ú=ú>ú>=ú<ú<=ú==ú!=ú&&ú||ú+=ú-=ú*=ú/=ú%=ú(r›   rý   rC   zCUnary operators as a part of binary operators is not supported yet!)ú&ú|ú^z<<z>>z.Bitwise operator has not been implemented yet!)z&=z|=z^=z<<=z>>=z8Shorthand bitwise operator has not been implemented yet!z&Given token {} is not implemented yet!Ú
identifierrÒ   )r/   r.   Úbooleanr   )rþ   rŸ   r|   r3   Ú	TokenKindÚPUNCTUATIONrO   r€   Úlenr«   ÚpopÚperform_operationÚpriority_ofrº   Ú
IDENTIFIERÚLITERALÚKEYWORD)
r7   r¢   r   rÿ   Úcombined_variables_stackÚoperators_stackÚtokenÚrhsÚlhsÚoperators
             r8   rõ   z(CCodeConverter.transform_binary_operator   sÈ  € ô( ˜$Ÿ/™/Ó+Ó,ˆFòˆNð (*Ð$ð !ˆOð  ó V1�ð —:‘:¤§¡×!:Ñ!:Ó:ð —~‘~¨Ò,Ø'×.Ñ.¨sÕ3àŸ™¨3Ò.ñ  /Ø /°Ñ 3°sÒ :Ü"Ð#;Ó<¸qÒ@Ü&9ð%5ó'6ð !6ð #;×">Ñ">Ó"@˜CØ":×">Ñ">Ó"@˜CØ'6×':Ñ':Ó'<˜HØ4×;Ñ;Ø $× 6Ñ 6Ø # S¨(ó!4ô5ñ  /Ø /°Ñ 3°sÓ :ð (×+Ñ+Õ-ð Ÿ™¨>Ñ9Ù.Ø $× 0Ñ 0°·±Ó @Ø#×/Ñ/Ø+¨BÑ/ó 1ò!1ô  #Ð#;Ó<¸qÒ@Ü&9ð%5ó'6ð !6ð #;×">Ñ">Ó"@˜CØ":×">Ñ">Ó"@˜CØ'6×':Ñ':Ó'<˜HØ4×;Ñ;Ø $× 6Ñ 6Ø # S¨(ó!4ô5ñ  /Ø $× 0Ñ 0°·±Ó @Ø#×/Ñ/Ø+¨BÑ/ó 1ó!1ð  (×.Ñ.¨u¯~©~Ö>ð Ÿ™Ð+FÑFÜ1ð/ó0ð 0ð
 Ÿ™ð ,ñ ä1ð/ó0ð 0ô 2ØDß#™V E§N¡NÓ3ó5ð 5ð
 —Z‘Z¤3§=¡=×#;Ñ#;Ò;Ø,×3Ñ3ØŸ™¨Ð6ö8ð —Z‘Z¤3§=¡=×#8Ñ#8Ò8Ø,×3Ñ3ØŸ™¨Ð3ö5ð —j‘j¤C§M¡M×$9Ñ$9Ò9ØŸ™Ð*;Ñ;Ø,×3Ñ3ØŸ™¨Ð3ö5ô .Ø@ß™ §¡Ó/ó1ð 1ðiV1ñr "ÜÐ/Ó0°1Ò4Ü-ð)ó*ð *ð /×2Ñ2Ó4�Ø.×2Ñ2Ó4�Ø*×.Ñ.Ó0�Ø(×/Ñ/Ø×*Ñ*¨3°°XÓ>ô@ò "ð ,¨BÑ/°Ñ2Ð2r:   c                 ó6   — |dv ry|dv ry|dv ry|dv ry|d	v ry
y)z%To get the priority of given operator)r  r  r  r  r  r  rD   )r  r  rC   ©r	  r
  r  r  r  r  rB   )rø   rù   rA   )r  r  r  é   r   rV   )r7   Úops     r8   r  zCCodeConverter.priority_of«  s>   € àÐ8Ñ8ØØ�\Ñ!ØØÐ7Ñ7ØØ�ZÑØØ�_Ñ$ØØr:   c           	      ó^  — | j                  |«      }| j                  |«      }|dk(  rt        ||«      dgS |dk(  rt        || «      dgS |dk(  rt        ||«      dgS |dk(  r!t        |t        |t	        d«      «      «      dgS |dk(  rt        ||«      dgS |dv rt        |||«      dgS |d	k(  r t        t        |«      t        |«      «      dgS |d
k(  r t        t        |«      t        |«      «      dgS |dk(  rt        t        |«      |«      dgS |dv rt        t        |«      |d   |«      dgS y)zÉPerforms operation supported by the SymPy core

            Returns
            =======

            combined_variable: list
                contains variable content and type of variable

            rø   rã   rù   r  r  rý   r  r*  r  r  r  )r  r  r  r  r  r   N)Úget_expr_for_operandr#   r%   r&   r   r$   r'   r(   r)   r+   r   r   r   )r7   r'  r&  r,  Ú	lhs_valueÚ	rhs_values         r8   r  z CCodeConverter.perform_operation¹  sZ  € ð ×1Ñ1°#Ó6ˆIØ×1Ñ1°#Ó6ˆIØ�SŠyÜ˜I yÓ1°6Ð:Ð:Ø�SŠyÜ˜I¨	 zÓ2°FÐ;Ð;Ø�SŠyÜ˜I yÓ1°6Ð:Ð:Ø�SŠyÜ˜I¤s¨9´g¸b³kÓ'BÓCÀVÐLÐLØ�SŠyÜ˜I yÓ1°6Ð:Ð:ØÐ7Ñ7Ü˜I y°"Ó5°vÐ>Ð>Ø�TŠzÜœJ yÓ1´:¸iÓ3HÓIÈ6ÐRÐRØ�TŠzÜœ: iÓ0´*¸YÓ2GÓHÈ&ÐQÐQØ�SŠyÜ"¤8¨IÓ#6¸	ÓBÀFÐKÐKØÐ3Ñ3Ü"¤8¨IÓ#6¸¸1¹¸yÓIÈ6ÐRÐRð 4r:   c                 óü   — |d   dk(  rt        |d   «      S |d   dk(  r5d|d   v rt        t        |d   «      «      S t        t	        |d   «      «      S |d   dk(  r|d   S |d   dk(  r|d   dk(  rt
        S t        S y	)
zÓGives out SymPy Codegen AST node

            AST node returned is corresponding to
            combined variable passed.Combined variable contains
            variable content and type of variable

            rD   r  r   rÒ   ú.rã   r  r/   N)r,   r	   r]   r   r\   r/   r.   )r7   Úcombined_variables     r8   r.  z#CCodeConverter.get_expr_for_operandÚ  sª   € ð ! Ñ# |Ò3ÜÐ/°Ñ2Ó3Ð3Ø  Ñ# yÒ0ØÐ+¨AÑ.Ñ.Ü ¤Ð'8¸Ñ';Ó!<Ó=Ð=ä"¤3Ð'8¸Ñ';Ó#<Ó=Ð=Ø  Ñ# vÒ-Ø(¨Ñ+Ð+Ø  Ñ# yÒ0Ø#4°QÑ#7¸6Ò#Aœ4ÐLÄuÐLð 1r:   c                 ó   — t         S )z'Handles Null Statement and returns None)r   rØ   s     r8   Útransform_null_stmtz"CCodeConverter.transform_null_stmtî  s   € äˆKr:   c                 óê   — |j                  «       }| j                  t        |«      «      }| j                  t        |«      «      }t        |t        «      r	t        |Ž }nt        |«      }t        ||«      S )a  Transformation function for handling while statement

            Returns
            =======

            while statement : Codegen AST Node
                contains the while statement node having condition and
                statement block

            )r{   r�   r¬   r¶   rþ   r   r   )r7   r¢   r¼   Ú	conditionÚ
statementsÚstatement_blocks         r8   Útransform_while_stmtz#CCodeConverter.transform_while_stmtò  sa   € ð ×(Ñ(Ó*ˆHàŸ™¤t¨H£~Ó6ˆIØŸ™¬¨X«Ó7ˆJä˜*¤dÔ+Ü"+¨ZÐ"8‘ä"+¨JÓ"7�ä˜ OÓ4Ð4r:   )!rR   rS   rT   rU   r9   rw   r‘   r�   r¿   rË   rÐ   rÔ   rÖ   rÙ   rÜ   rÞ   rà   rä   ræ   rê   rì   rî   rñ   ró   rö   r  rõ   r  r  r.  r5  r:  Ú__classcell__)ro   s   @r8   rX   rX   U   s¤   ø„ ñ	ô	ò8"	"òH&	"òP	!ò6t	òl6	òpD	òL	ò4	 ò4
	ò	&ò2	6ò$	ò#	òJ	!ò#	1òJ	>ò	ò(!	òF	=ò	8ò&8	6òtI	3òV	ò	SòB	Mò(	ö	5r:   rX   c                   ó   — e Zd Zd„ Zy)rX   c                 ó   — t        d«      ‚)NzModule not Installed)ÚImportError)r7   rr   Úkwargss      r8   r9   zCCodeConverter.__init__  s   € ÜÐ4Ó5Ð5r:   N)rR   rS   rT   r9   rV   r:   r8   rX   rX     s   „ ó	6r:   c                 ó¨   — t        «       }t        j                  j                  | «      r|j	                  | g ¬«      }|S |j                  | g ¬«      }|S )zòFunction for converting a C source code

    The function reads the source code present in the given file and parses it
    to give out SymPy Expressions

    Returns
    =======

    src : list
        List of Python expression strings

    )rƒ   )rX   rt   ru   Úexistsrw   r‘   )r�   Ú	converterÚsrcs      r8   Úparse_crD    sQ   € ô Ó €IÜ	‡w�w‡~�~�fÔØ�o‰o˜f¨bˆoÓ1ˆð €Jð ×!Ñ! &°"Ð!Ó5ˆØ€Jr:   )8Úsympy.externalr   rt   r3   Úsympy.codegen.astr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úsympy.codegen.cnodesr   r    r!   r"   Ú
sympy.corer#   r$   r%   r&   r'   Úsympy.logic.boolalgr(   r)   r*   r+   Úsympy.core.symbolr,   Úsympy.core.sympifyr-   r.   r/   r    r‰   r1   rX   rD  rV   r:   r8   ú<module>rL     sž   ðÝ (Û 	á�N°ZÀ(ÀÐ4LÔM€ð$ñL ÷-÷ -÷ -÷ -÷ -÷ -ó -÷
%ó %ç2Õ2ß<Ó<Ý(Ý*ß1ÛÛ÷!ñ !ô2r5˜ô r5óx÷6ñ 6ó
r:   