HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/jinja2/__pycache__/optimizer.cpython-310.pyc
o

%wer�@sddZddlZddlmZddlmZejrddlm	Z	dej
dd	d
ej
fdd�ZGd
d�de�ZdS)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�returncCst|�}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)rr�	optimizer�r�I/home/arjun/projects/env/lib/python3.10/site-packages/jinja2/optimizer.py�optimizesrcs@eZdZddd�Zdejdejd	ejdejf�fd
d�Z�Z	S)
r	r�t.Optional[Environment]rNcCs
||_dS)N)r)�selfrrrr�__init__s
zOptimizer.__init__r�args�kwargscslt�j|g|�Ri|��}t|tj�r4ztjj|�|r|dnd�|j|j	d�WStj
y3Y|Sw|S)Nr)�linenor)�super�
generic_visit�
isinstancer�Expr�Const�from_untrusted�as_constrr�
Impossible)rrrr��	__class__rrrs��zOptimizer.generic_visit)rrrN)
�__name__�
__module__�__qualname__rrrr
�Anyr�
__classcell__rrr rr	s
����r	)
�__doc__�typingr
�r�visitorr�
TYPE_CHECKINGrrrrr	rrrr�<module>s