| Server IP : 94.16.115.136 / Your IP : 216.73.217.106 Web Server : Apache/2.4.52 (Ubuntu) System : Linux rogerrabbit 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 User : bkillingseder ( 1001) PHP Version : 8.1.2-1ubuntu2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /snap/core22/current/usr/lib/python3/dist-packages/jinja2/__pycache__/ |
Upload File : |
o
�:�`r � @ sd d Z ddlZddlmZ ddlmZ ejrddlm Z dej
dd d
ej
fdd�ZG d
d� de�ZdS )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 C s t |�}t�tj|�| ��S )z^The context hint can be used to perform an static optimization
based on the context given.)� Optimizer�t�castr �Node�visit)r r � optimizer� r �2/usr/lib/python3/dist-packages/jinja2/optimizer.py�optimize s r c s@ e Zd Zddd�Zdejdejd ejdejf� fd
d�Z� Z S )
r r �t.Optional[Environment]r Nc C s
|| _ d S )N)r )�selfr r r r �__init__ s
zOptimizer.__init__r �args�kwargsc sl t � j|g|�R i |��}t|tj�r4ztjj|�|r|d nd �|j| j d�W S tj
y3 Y |S w |S )Nr )�linenor )�super�
generic_visit�
isinstancer �Expr�Const�from_untrusted�as_constr r �
Impossible)r r r r �� __class__r r r s ��zOptimizer.generic_visit)r r r N)
�__name__�
__module__�__qualname__r r r r
�Anyr �
__classcell__r r r r r s
����r )
�__doc__�typingr
� r �visitorr �
TYPE_CHECKINGr r r r r r r r r �<module> s