HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-86-generic #87-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 22 18:03:36 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/jinja2/__pycache__/optimizer.cpython-312.pyc
�

��+br���dZddlZddlmZddlmZejrddlm	Z	dejdd	d
ejfd�ZGd�d
e�Zy)a�The optimizer tries to constant fold expressions and modify the AST
in place so that it should be faster to evaluate.

Because the AST does not contain all the scoping information and the
compiler has to find that out, we cannot do all the optimizations we
want. For example, loop unrolling doesn't work because unrolled loops
would have a different scope. The solution would be a second syntax tree
that stored the scoping rules.
�N�)�nodes)�NodeTransformer)�Environment�node�environmentr�returnc�~�t|�}tjtj|j|��S)z^The context hint can be used to perform an static optimization
    based on the context given.)�	Optimizer�t�castr�Node�visit)rr�	optimizers   �2/usr/lib/python3/dist-packages/jinja2/optimizer.py�optimizers,���+�&�I��6�6�%�*�*�i�o�o�d�3�4�4�c���eZdZdd�Zdej
dejdejdej
f�fd�Z�xZ	S)rr	c��||_y)N)r)�selfrs  r�__init__zOptimizer.__init__s
��&��rr�args�kwargsc�0��t�|�|g|��i|��}t|tj�rM	tj
j
|j|r|dnd�|j|j��S|S#tj$rY|SwxYw)Nr)�linenor)�super�
generic_visit�
isinstancer�Expr�Const�from_untrusted�as_constrr�
Impossible)rrrr�	__class__s    �rrzOptimizer.generic_visits�����w�$�T�;�D�;�F�;���d�E�J�J�'�
��{�{�1�1��M�M�T�$�q�'�t�<��;�;� $� 0� 0�2�������#�#�
����
�s�AA>�>B�B)rzt.Optional[Environment]r	N)
�__name__�
__module__�__qualname__rrrr�Anyr�
__classcell__)r$s@rrrsB���'���J�J��'(�u�u��89����	����rr)
�__doc__�typingr�r�visitorr�
TYPE_CHECKINGrrrrr�rr�<module>r0sM�����$��?�?�(�5�5�:�:�5�M�5�e�j�j�5���r