Ë
    pPêj¤5  ã                  óþ  — U d Z ddlmZ ddlmZmZmZmZ ddl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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$ ddl%m&Z& ddl'm(Z( dd	l)m*Z* dd
l+m,Z,m-Z-m.Z.m/Z/  e0g d¢«      Z1de2d<    e0g d¢«      Z3de2d<   ed   Z4 G d„ de«      Z5d)d„Z6d)d„Z7d*d„Z8d+d„Z9d)d„Z:d*d„Z;d,d„Z<d-d„Z=d.d„Z>d/d„Z?d0d„Z@d1d„ZA	 	 	 	 	 	 	 	 d2d„ZBd3d „ZCd4d!„ZDd5d"„ZEd6d#„ZFd7d$„ZGd8d%„ZHd9d&„ZId:d'„ZJy();zFVarious utilities that don't depend on other modules in mypyc.irbuild.é    )Úannotations)ÚAnyÚFinalÚLiteralÚ	TypedDict)ÚNotRequired)Ú	ARG_NAMEDÚARG_NAMED_OPTÚARG_OPTÚARG_POSÚGDEFÚArgKindÚAssignmentStmtÚ	BytesExprÚCallExprÚClassDefÚ	DecoratorÚ
ExpressionÚ	FloatExprÚFuncDefÚIntExprÚNameExprÚOverloadedFuncDefÚRefExprÚStrExprÚTempNodeÚ	TupleExprÚ	UnaryExprÚVarÚis_class_var)Úrefers_to_fullname)ÚFINAL_DECORATOR_NAMES)ÚErrors)ÚClassIR)ÚRTypeÚis_none_rprimitiveÚis_object_rprimitiveÚis_optional_type)Únative_classÚallow_interpreted_subclassesÚserializableÚfree_list_lenÚacycliczFinal[frozenset[MypycAttr]]ÚMYPYC_ATTRS)zdataclasses.dataclasszattr.sz
attr.attrsr   ÚDATACLASS_DECORATORSc                  ó@   — e Zd ZU ded<   ded<   ded<   ded<   ded<   y)	Ú
MypycAttrszNotRequired[bool]r)   r*   r+   zNotRequired[int]r,   r-   N)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__© ó    úW/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/mypyc/irbuild/util.pyr1   r1   4   s    … Ø#Ó#Ø"3Ó3Ø#Ó#Ø#Ó#ØÔr7   r1   c                ó"   — t        | t        «      S ©N)r!   r"   ©Úds    r8   Úis_final_decoratorr=   <   s   € Ü˜aÔ!6Ó7Ð7r7   c                óD   — t        | t        «      xr | j                  dk(  S )Nzmypy_extensions.trait)Ú
isinstancer   Úfullnamer;   s    r8   Úis_trait_decoratorrA   @   s   € Ü�aœÓ!ÒK a§j¡jÐ4KÑ&KÐKr7   c                ój   — t        d„ | j                  D «       «      xs | j                  j                  S )Nc              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr:   )rA   ©Ú.0r<   s     r8   ú	<genexpr>zis_trait.<locals>.<genexpr>E   s   è ø€ Ò>¨Ô! !×$Ñ>ùó   ‚)ÚanyÚ
decoratorsÚinfoÚis_protocol©Úcdefs    r8   Úis_traitrN   D   s&   € ÜÑ>¨d¯o©oÔ>Ó>ÒWÀ$Ç)Á)×BWÑBWÐWr7   c                ó  — t        | t        «      r0| j                  t        v r| j                  j	                  d«      d   S t        | t
        «      r»t        | j                  t        «      r¡| j                  j                  t        v r…| j                  j                  j	                  d«      d   }|dk(  rVd| j                  v rH| j                  | j                  j                  d«         }t        |t        «      r|j                  dk(  ry|S y )Nú.r   ÚattrÚauto_attribsÚTrueú	attr-auto)r?   r   r@   r/   Úsplitr   ÚcalleeÚ	arg_namesÚargsÚindexr   Úname)r<   rZ   Úautos      r8   Údataclass_decorator_typer\   H   sÍ   € Ü�!”WÔ !§*¡*Ô0DÑ"DØ�z‰z×Ñ Ó$ QÑ'Ð'ä�1”hÔÜ�q—x‘x¤Ô)Ø�H‰H×ÑÔ!5Ñ5à�x‰x× Ñ ×&Ñ& sÓ+¨AÑ.ˆØ�6Š>˜n°·±Ñ;ð —6‘6˜!Ÿ+™+×+Ñ+¨NÓ;Ñ<ˆDÜ˜$¤Ô)¨d¯i©i¸6Ò.AØ"Øˆàr7   c                ó   — t        | «      d uS r:   )r\   r;   s    r8   Úis_dataclass_decoratorr^   \   s   € Ü# AÓ&¨dÐ2Ð2r7   c                ó:   — t        d„ | j                  D «       «      S )Nc              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr:   )r^   rD   s     r8   rF   zis_dataclass.<locals>.<genexpr>a   s   è ø€ ÒB¨QÔ% a×(ÑBùrG   )rH   rI   rL   s    r8   Úis_dataclassra   `   s   € ÜÑB°$·/±/ÔBÓBÐBr7   c                óH   — | j                   D ]  }t        |«      }|€Œ|c S  y r:   )rI   r\   )rM   r<   Útyps      r8   Údataclass_typerd   f   s.   € Ø�_‰_ò ˆÜ& qÓ)ˆØ‰?ØŠJðð r7   c                ó¶   — | j                   r| j                  sy| j                  ry|j                  sy|j                  ryt        |«      �y|j                  ryy)aÀ  Is a member a final attribute initialized in class body ("X: Final = <value>")?

    The value is the same for every instance, so we don't give these struct
    slots. Instead, we let the general final-name machinery own it: the value
    is stored once in a module-level static and set on the type object (see
    ExtClassBuilder.add_attr), and reads are constant folded or loaded from
    the static.

    See ClassIR.class_final_attributes.
    FT)Úis_finalÚhas_explicit_valueÚfinal_set_in_initÚis_ext_classÚbuiltin_baserd   Úerror_overlap)ÚvarÚirrM   Ú
attr_rtypes       r8   Úis_class_body_finalro   n   sW   € ð �<Š<˜s×5Ò5ØØ
×ÒàØ�?Š?àØ	‡‚ð Ü�dÓÐ'àØ×Òð
 Ør7   c                ó4   — |dk(  ry|dv r| j                   duS y)a*  Whether a class-level default assignment is skipped when emitting
    __mypyc_defaults_setup, based on class type.

    - attr (auto_attribs=False): skip all (handled by attr.ib machinery).
    - dataclasses / attr-auto: skip annotated assignments.
    - regular extension class: skip nothing.
    rQ   T)ÚdataclassesrT   NF)Útype)ÚstmtÚcls_types     r8   Ú_defaults_skipru   ’   s*   € ð �6ÒØØÐ/Ñ/Ø�y‰y Ð$Ð$Ør7   c                ó²  — | j                   d   }t        |t        «      rt        |«      ryt        | j                  t
        «      ry|j                  }|dv s||j                  vryt        | |«      ryt        | j                  t        «      rJ| j                  j                  dk(  r1|j                  |   }t        |«      st        |«      st        |«      sy|S )aY  Return the attribute name if `stmt` is a class-level default assignment
    that __mypyc_defaults_setup should emit; otherwise None.

    Single source of truth for the predicate used by both
    mypyc.irbuild.classdef.find_attr_initializers (IR build) and
    mypyc.irbuild.prepare._has_own_default_attrs (prepare-phase decl registration).
    r   N)Ú	__slots__Ú__deletable__úbuiltins.None)Úlvaluesr?   r   r    Úrvaluer   rZ   Ú
attributesru   r   r@   r(   r'   r&   )rs   rm   rt   ÚlvaluerZ   Ú	attr_types         r8   Údefault_attr_namer   ¡   s°   € ð �\‰\˜!‰_€FÜ�fœhÔ'¬<¸Ô+?ØÜ�$—+‘+œxÔ(ØØ�;‰;€DØÐ-Ñ-°¸R¿]¹]Ñ1JØÜ�d˜HÔ%ØÜ�$—+‘+œwÔ'¨D¯K©K×,@Ñ,@ÀOÒ,SØ—M‘M $Ñ'ˆ	ä  Ô+Ü(¨Ô3Ü& yÔ1àØ€Kr7   c                óT  — t        | t        t        t        f«      r| j                  S t        | t
        «      r| j                  dk(  ryt        | t
        «      r| j                  dk(  ryt        | t
        «      r| j                  dk(  ryt        | t        «      r| j                  S t        S )zcConvert an expression from a mypyc_attr decorator to a value.

    Supports a pretty limited range.úbuiltins.TrueTúbuiltins.FalseFry   N)r?   r   r   r   Úvaluer   r@   ÚNotImplemented©Úes    r8   Úget_mypyc_attr_literalr‡   ¾   s€   € ô �!”gœw¬	Ð2Ô3Ø�w‰wˆÜ	�A”wÔ	 A§J¡J°/Ò$AØÜ	�A”wÔ	 A§J¡JÐ2BÒ$BØÜ	�A”wÔ	 A§J¡J°/Ò$AØÜ	�A”wÔ	Ø�w‰wˆÜÐr7   c                óŽ   — t        | t        «      r5t        | j                  t        «      r| j                  j                  dk(  r| S y)zCCheck if an expression is a call to mypyc_attr and return it if so.zmypy_extensions.mypyc_attrN)r?   r   rV   r   r@   r;   s    r8   Úget_mypyc_attr_callr‰   Ï   s7   € ô 	�1”hÔÜ�q—x‘x¤Ô)Ø�H‰H×ÑÐ!=Ò=àˆØr7   c                ór  ‡‡‡
‡— i Š
i Šdˆ
ˆˆˆfd„}| j                   D ]”  }t        |«      x}sŒ|j                  }t        |j                  |j
                  «      D ]U  \  }}|€9t        |t        «      r ||j                  d|«       Œ-‰j                  d‰|«       ŒAt        |«      }	 |||	|«       ŒW Œ– ‰
‰fS )zJCollect all the mypyc_attr attributes on a class definition or a function.c                óÄ   •— | t         v r|‰| <   |‰| <   y ‰j                  d| › d�‰|«       dj                  t        t         «      «      }‰j	                  d|› d�‰|«       y )Nú"z!" is not a supported "mypyc_attr"z", "zsupported keys: ")r.   ÚerrorÚjoinÚsortedÚnote)Úkeyrƒ   ÚlineÚsupported_keysÚattrsÚerrorsÚlinesÚpaths       €€€€r8   Úset_mypyc_attrz'get_mypyc_attrs.<locals>.set_mypyc_attrá   se   ø€ Ø”+ÑØˆE�#‰JØˆE�#ŠJà�L‰L˜1˜S˜EÐ!BÐCÀTÈ4ÔPØ#Ÿ[™[¬´Ó)<Ó=ˆNØ�K‰KÐ+¨NÐ+;¸1Ð=¸tÀTÕJr7   Tz>All "mypyc_attr" positional arguments must be string literals.)r‘   Ústrrƒ   r   r’   ÚintÚreturnÚNone)rI   r‰   r’   ÚziprW   rX   r?   r   rƒ   r�   r‡   )rs   r—   r•   r˜   Údecr<   r’   rZ   ÚargÚ	arg_valuer”   r–   s    ``       @@r8   Úget_mypyc_attrsr¡   Ú   sÃ   û€ ð €EØ"$€E÷Kð Kð �‰ò :ˆÜ# CÓ(Ð(ˆ1Ñ(Ø—6‘6ˆDÜ  §¡¨a¯f©fÓ5ò :‘	��cØ�<Ü! #¤wÔ/Ù& s§y¡y°$¸Õ=àŸ™Ø\Ø Ø õô !7°sÓ ;�IÙ" 4¨°DÕ9ñ:ð:ð" �%ˆ<Ðr7   c                ó’   — t        | ||«      }|du ryt        |«      \  }}|du r"|s |j                  d|› �| |j                  «       |S )NFTzEClass is marked as native_class=True but it can't be a native class. )Úget_explicit_native_classÚis_implicit_extension_classr�   r’   )r—   rM   r•   Úexplicit_native_classÚimplicit_extension_classÚreasons         r8   Úis_extension_classr¨   þ   se   € ä5°d¸DÀ&ÓIÐð  Ñ%Øä'BÀ4Ó'HÑ$Ð˜fð  Ñ$Ñ-EØ�‰ØSÐTZÐS[Ð\ØØ�I‰Iô	
ð $Ð#r7   c                óŒ  — |j                   D ]µ  }t        |«      }|sŒt        |j                  «      D ]�  \  }}|dk7  rŒ|j                  |   }t        |t        «      s |j                  d| |j                  «         y|j                  dk(  r  y|j                  dk(  r  y|j                  d| |j                  «         y Œ· y)záReturn value of @mypyc_attr(native_class=True/False) decorator.

    Look for a @mypyc_attr decorator with native_class=True/False and return
    the value assigned or None if it doesn't exist. Other values are an error.
    r)   z1native_class must be used with True or False onlyNÚFalseFrS   T)
rI   r‰   Ú	enumeraterW   rX   r?   r   r�   r’   rZ   )r—   rM   r•   r<   Úmypyc_attr_callÚirZ   rŸ   s           r8   r£   r£     sÅ   € ð �_‰_ò ˆÜ-¨aÓ0ˆÙØä  ×!:Ñ!:Ó;ò 	‰GˆAˆtØ�~Ò%Øà!×&Ñ& qÑ)ˆCÜ˜c¤8Ô,Ø—‘ÐPÐRVÐX\×XaÑXaÔbÚà�x‰x˜7Ò"ÚØ—‘˜VÒ#Úà—‘ÐPÐRVÐX\×XaÑXaÔbÚñ	ðð* r7   c                ój  — | j                   D ]3  }t        |«      rŒt        |«      rŒt        |«      rŒ't	        |«      rŒ3 y | j
                  j                  ry| j
                  j                  ry| j
                  j                  r-| j
                  j                  j                  j                  dvryy)zXCheck if class can be extension class and return a user-friendly reason it can't be one.)FzUClasses that have decorators other than supported decorators can't be native classes.)Fz*TypedDict classes can't be native classes.)Fz+NamedTuple classes can't be native classes.)zabc.ABCMetaztyping.TypingMetaztyping.GenericMeta)Fz_Classes with a metaclass other than ABCMeta, TypingMeta or GenericMeta can't be native classes.)TÚ )rI   rA   r^   r‰   r=   rJ   Útypeddict_typeÚis_named_tupleÚmetaclass_typerr   r@   )rM   r<   s     r8   r¤   r¤   3  s˜   € ð �_‰_ò ˆä" 1Õ%Ü*¨1Õ-Ü'¨Õ*Ü& qÕ)ñðð ‡y�y×ÒØBØ‡y�y×ÒØCØ‡y�y×Ò D§I¡I×$<Ñ$<×$AÑ$A×$JÑ$Jð Sñ %ð

ð
 r7   c                ó’   — t        | t        «      r| j                  sJ ‚| j                  } t        | t        «      r| j                  } | S r:   )r?   r   Úimplr   Úfunc)Úops    r8   Úget_func_defr·   T  s9   € Ü�"Ô'Ô(Ø�wŠwˆˆwØ�W‰WˆÜ�"”iÔ Ø�W‰WˆØ€Ir7   c                ó^   — | j                   }t        |t        «      r|j                  S |xs | S )z>Return the symbol used to store a possibly redefined function.)Úoriginal_defr?   r   rµ   )ÚfdefÚoriginals     r8   Úget_func_target_symbolr¼   ]  s,   € à× Ñ €HÜ�(œIÔ&Ø�}‰}ÐØÒ�tÐr7   c                óB   — | t         k(  rt        S | t        k(  rt        S | S )z>Find the concrete version of an arg kind that is being passed.)r   r   r
   r	   )Úkinds    r8   Úconcrete_arg_kindr¿   e  s!   € àŒw‚ÜˆØ	”Ò	ÜÐàˆr7   c                ó  — t        | t        t        t        t        f«      xsÞ t        | t
        «      xr1 | j                  dk(  xr  t        | j                  t        t        f«      xs™ t        | t        «      xr t        d„ | j                  D «       «      xsi t        | t        «      xrW | j                  t        k(  xrB | j                  dv xs2 t        | j                  t         «      xr | j                  j"                  S )aS  Check whether we allow an expression to appear as a default value.

    We don't currently properly support storing the evaluated
    values for default arguments and default attribute values, so
    we restrict what expressions we allow.  We allow literals of
    primitives types, None, and references to Final global
    variables.
    ú-c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr:   )Úis_constant)rE   r†   s     r8   rF   zis_constant.<locals>.<genexpr>{  s   è ø€ Ò,MÀ¬[¸¯^Ñ,MùrG   )r�   r‚   ry   )r?   r   r   r   r   r   r¶   Úexprr   ÚallÚitemsr   r¾   r   r@   Únoder   rf   r…   s    r8   rÃ   rÃ   o  sÇ   € ô 	�1”w¤	¬7´IÐ>Ó?ò 
	
Ü�qœ)Ó$Òa¨¯©°©Òa¼ÀAÇFÁFÌWÔV_ÐL`Ó9aò
	
ä�qœ)Ó$ÒM¬Ñ,MÀQÇWÁWÔ,MÓ)Mò
	
ô �qœ'Ó"ò Ø—‘œ$‘òð —
‘
ÐRÐRò AÜ˜qŸv™v¤sÓ+Ò?°·±·±ðr7   c                óV   — t        | d«      j                  d«      j                  d«      S )zßConvert a string representing bytes into actual bytes.

    This is needed because the literal characters of BytesExpr (the
    characters inside b'') are stored in BytesExpr.value, whose type is
    'str' not 'bytes'.
    Úutf8zunicode-escapezraw-unicode-escape)ÚbytesÚdecodeÚencode)rƒ   s    r8   Úbytes_from_strrÍ   ‡  s)   € ô �˜Ó×&Ñ&Ð'7Ó8×?Ñ?Ð@TÓUÐUr7   N)r<   r   r›   Úbool)rM   r   r›   rÎ   )r<   r   r›   ú
str | None)rM   r   r›   rÏ   )
rl   r   rm   r$   rM   r   rn   r%   r›   rÎ   )rs   r   rt   rÏ   r›   rÎ   )rs   r   rm   r$   rt   rÏ   r›   rÏ   )r†   r   r›   r   )r<   r   r›   zCallExpr | None)rs   zClassDef | Decoratorr—   r™   r•   r#   r›   z'tuple[MypycAttrs, dict[MypycAttr, int]])r—   r™   rM   r   r•   r#   r›   rÎ   )r—   r™   rM   r   r•   r#   r›   zbool | None)rM   r   r›   ztuple[bool, str])r¶   z'FuncDef | Decorator | OverloadedFuncDefr›   r   )rº   r   r›   zFuncDef | Var)r¾   r   r›   r   )r†   r   r›   rÎ   )rƒ   r™   r›   rÊ   )KÚ__doc__Ú
__future__r   Útypingr   r   r   r   Útyping_extensionsr   Ú
mypy.nodesr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    Úmypy.semanalr!   Ú
mypy.typesr"   Úmypyc.errorsr#   Úmypyc.ir.class_irr$   Úmypyc.ir.rtypesr%   r&   r'   r(   Ú	frozensetr.   r5   r/   Ú	MypycAttrr1   r=   rA   rN   r\   r^   ra   rd   ro   ru   r   r‡   r‰   r¡   r¨   r£   r¤   r·   r¼   r¿   rÃ   rÍ   r6   r7   r8   ú<module>rÜ      s  ðÚ Lå "ç 1Ó 1Ý )÷÷ ÷ ÷ ÷ ÷ ó õ4 ,Ý ,Ý Ý %ß ]Ó ]á+4Ú`ó,€Ð(ó ñ (Ò(YÓZÐ �eÓ Zð Ø^ñ€	ô
�ô ó8óLóXóó(3óCóó!óHóó:ó"ð!Ø
ð!Ø&)ð!Ø39ð!à,ó!óH$ó,ó>óBóóóô0Vr7   