ó ,ōQc@sIdZddlmZddlmZd„Zdefd„ƒYZdS(s[ jinja2.optimizer ~~~~~~~~~~~~~~~~ The jinja optimizer is currently trying to constant fold a few expressions and modify the AST in place so that it should be easier to evaluate it. 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 scoping. The solution would be a second syntax tree that has the scoping rules stored. :copyright: (c) 2010 by the Jinja Team. :license: BSD. iĸĸĸĸ(tnodes(tNodeTransformercCst|ƒ}|j|ƒS(s^The context hint can be used to perform an static optimization based on the context given.(t Optimizertvisit(tnodet environmentt optimizer((s4/usr/lib/python2.7/site-packages/jinja2/optimizer.pytoptimizes RcBsteZd„Zd„Zd„ZeZZZZZ Z Z Z Z ZZZZZZZZZZ[RS(cCs ||_dS(N(R(tselfR((s4/usr/lib/python2.7/site-packages/jinja2/optimizer.pyt__init__ scCsŪ|jtjƒdk r%|j|ƒSy|j|jƒjƒ}Wntjk ra|j|ƒSX|rt|j }n |j }g}x$|D]}|j |j |ƒƒqŠW|S(sEliminate dead code.N( tfindRtBlocktNonet generic_visitRttesttas_constt Impossibletbodytelse_textendt visit_list(RRtvalRtresult((s4/usr/lib/python2.7/site-packages/jinja2/optimizer.pytvisit_If#s    cCsW|j|ƒ}y,tjj|jƒd|jd|jƒSWntjk rR|SXdS(sDo constant folding.tlinenoRN(R RtConsttfrom_untrustedRRRR(RR((s4/usr/lib/python2.7/site-packages/jinja2/optimizer.pytfold6s (t__name__t __module__R RRt visit_Addt visit_Subt visit_Mult visit_Divtvisit_FloorDivt visit_Powt visit_Modt visit_Andtvisit_Ort visit_Post visit_Negt visit_Nott visit_Comparet visit_Getitemt visit_Getattrt visit_Callt visit_Filtert visit_Testtvisit_CondExpr(((s4/usr/lib/python2.7/site-packages/jinja2/optimizer.pyRs    NN(t__doc__tjinja2Rtjinja2.visitorRRR(((s4/usr/lib/python2.7/site-packages/jinja2/optimizer.pyts