3
U'ícr ã @ s` d Z ddlZddlmZ ddlmZ ejr6ddlm Z ej
dej
dd d
ZG dd deZdS )
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)ÚEnvironmentr )ÚnodeÚenvironmentÚreturnc C s 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)r r Z optimizer© r ú2/tmp/pip-build-gk9425m9/Jinja2/jinja2/optimizer.pyÚoptimize s r c s@ e Zd ZdddddZejejejejd fddZ Z S ) r zt.Optional[Environment]N)r r c C s