o
    ¦ƒðjß  ã                   @   sÌ   d dl mZ d dlmZ d dlmZmZmZmZm	Z	m
Z
 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 edƒ\ZZdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z dd„ Z!dd„ Z"dS )é    )Úsymbols)Úccode)ÚDeclarationÚVariableÚfloat64Úint64ÚStringÚ	CodeBlock)ÚalignofÚCommaOperatorÚgotoÚLabelÚPreDecrementÚPostDecrementÚPreIncrementÚPostIncrementÚsizeofÚunionÚstructzx yc                  C   s0   t tƒ} t| ƒdksJ ‚| j| jŽ | ksJ ‚d S )Nz
alignof(x))r
   Úxr   ÚfuncÚargs)Úax© r   ú¡/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/codegen/tests/test_cnodes.pyÚtest_alignof   s   r   c                  C   s:   t ttƒdt ƒ} t| ƒdksJ ‚| j| jŽ | ksJ ‚d S )Né   z(++(x), 2*x))r   r   r   r   r   r   )Úexprr   r   r   Útest_CommaOperator   s   r   c                  C   s   d} t | ƒ}|j|jŽ |ksJ ‚|t dƒksJ ‚t|ƒdks J ‚t| ƒ}t|ƒdks,J ‚|tdƒks4J ‚|tdƒks<J ‚ttƒg}t| |ƒ}|jtdƒksOJ ‚|j	t
ttƒƒksZJ ‚t|ƒdksbJ ‚ttƒttƒg}t| |ƒ}|jtdƒksxJ ‚|j	t
ttƒttƒƒks†J ‚t|ƒdksŽJ ‚d S )NÚ
early_exitÚfoobarzgoto early_exitzearly_exit:zearly_exit:
++(x);z#early_exit:
{
   ++(x);
   --(y);
})r   r   r   r   r   r   r   Únamer   Úbodyr	   r   Úy)ÚsÚgÚl1r"   Úl2r   r   r   Útest_goto_Label   s&   


r(   c                  C   ó0   t tƒ} | j| jŽ | ksJ ‚t| ƒdksJ ‚d S )Nz--(x))r   r   r   r   r   ©Úpr   r   r   Útest_PreDecrement3   ó   r,   c                  C   r)   )Nz(x)--)r   r   r   r   r   r*   r   r   r   Útest_PostDecrement9   r-   r.   c                  C   r)   )Nz++(x))r   r   r   r   r   r*   r   r   r   Útest_PreIncrement?   r-   r/   c                  C   r)   )Nz(x)++)r   r   r   r   r   r*   r   r   r   Útest_PostIncrementE   r-   r0   c                  C   s^   d} t | ƒ}t|ƒd|  ksJ ‚|j|jŽ |ksJ ‚|jrJ ‚| ¡ tdƒtdƒhks-J ‚d S )Nzunsigned intz
sizeof(%s)r   )r   r   r   r   Úis_AtomÚatomsr   )ÚtypenameÚszr   r   r   Útest_sizeofK   s   
 r5   c                  C   s¸   t ttd�t ttd�} }td| |gƒ}|j|jŽ |ksJ ‚|td| |fƒks)J ‚|td|| fƒks4J ‚t|jƒdks=J ‚t	|j
ƒdksFJ ‚tdd„ |j
D ƒƒsRJ ‚t|ƒdksZJ ‚d S )N©ÚtypeÚvec2r   c                 s   ó   � | ]}t |tƒV  qd S ©N©Ú
isinstancer   ©Ú.0Úargr   r   r   Ú	<genexpr>\   ó   € ztest_struct.<locals>.<genexpr>z)struct vec2 {
   double x;
   double y;
})r   r   r   r#   r   r   r   Ústrr!   ÚlenÚdeclarationsÚallr   )ÚvxÚvyr$   r   r   r   Útest_structT   s   ÿrH   c                  C   s¢   t ttd�t ttd�} }td| |gƒ}|j|jŽ |ksJ ‚|td| |fƒks)J ‚t|j	ƒdks2J ‚t
|jƒdks;J ‚tdd„ |jD ƒƒsGJ ‚t|ƒdksOJ ‚d S )Nr6   Údualuser   c                 s   r9   r:   r;   r=   r   r   r   r@   k   rA   ztest_union.<locals>.<genexpr>z,union dualuse {
   double x;
   int64_t y;
})r   r   r   r#   r   r   r   r   rB   r!   rC   rD   rE   r   )rF   rG   Úur   r   r   Ú
test_uniond   s   ÿrK   N)#Úsympy.core.symbolr   Úsympy.printing.codeprinterr   Úsympy.codegen.astr   r   r   r   r   r	   Úsympy.codegen.cnodesr
   r   r   r   r   r   r   r   r   r   r   r   r#   r   r   r(   r,   r.   r/   r0   r5   rH   rK   r   r   r   r   Ú<module>   s     4	