ڋs`}dZddlZddlmZddlmZejrddlm Z dej dd d ej fd Z Gd d eZ dS)aThe 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) Environmentnode environmentrreturnct|}tjtj||S)z^The context hint can be used to perform an static optimization based on the context given.) OptimizertcastrNodevisit)rr optimizers /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/jinja2/optimizer.pyoptimizers1+&&I 6%*iood33 4 44c`eZdZd dZdejdejdejdejffd ZxZ S) r rt.Optional[Environment]r Nc||_dS)N)r)selfrs r__init__zOptimizer.__init__s&rrargskwargsc4tj|g|Ri|}t|tjr_ tj||r|dnd|j|j S#tj $rYnwxYw|S)Nr)linenor) super generic_visit isinstancerExprConstfrom_untrustedas_constrr Impossible)rrrr __class__s rrzOptimizer.generic_visits%uww$T;D;;;F;; dEJ ' '  {11MMT";$q''t<<; $ 02 #     sABBB)rrr N) __name__ __module__ __qualname__rrrr Anyr __classcell__)r%s@rr r sy''''J'(u89 rr ) __doc__typingr rvisitorr TYPE_CHECKINGrrrrr rrr1s$$$$$$?)((((((55:5M5ej5555r