}Hc@sddkTddkTddklZddkTddkTddklZlZlZl Z ddk l Z l Z l Z ddklZlZddklZlZddkZdd d d d d ddgZedZdZeddZdZeeei ei!eei"ei#ei$ei%ei#ge&e'eei!eei#e(ei%e)fgfgZ*eddZ+e eei!ei%e,ei dei!fgeei#eei!dgZ-eddZ.eddZ/eddZ0defdYZhZ1dZ2dd?dYZ3dZ4dZ5d Z6e7e6e&fd!d"Z8e7e8e9e:fe7e8e9efd#Z;e7e8e9e<fd$Z=d e>e?fd%YZ@e7eAe@e0fd&e7ee@e0fd'ZBe7eAe@e.fd(e7ee@e.fd)ZCe7eAe@e/fd*e7ee@e/fd+ZDyeEWn#eFj odd,klEZEnXe7eAe@efd-e7eAe@e+fd.e7ee@efe7ee@e+fd/ZGed0ZHe7eHe:fe7eHefd1ZIe7eHe<fd2ZJe7eKe<eLe>fd3ZMd4ZNe7eNefe7eNe.fe7eNe0fe7eNe/fd5ZOe7eNePfd6e7eNe&fd7e7eQe@eRfd8ZSe2eTd9e2eUd:d;ZVd<ZWe7e4d=d>ZXdS(@i(t*(tclass_or_type_of(t SMIGeneratort ExprBuildertGetitemtIfElse(tdecoratet synchronizedtdecorate_assignment(t InstanceTypet ClassType(tbuildt parse_exprNt IsInstancet IsSubclasstTruthtIdentityt Comparisont IndexedEnginetpredicate_node_fort meta_functioncCsdS(s=Return a dispatch tree node argument appropriate for the exprN((tbuildertexprtcasestremaining_exprstmemo((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyRsc Cs|\}}||jo ||Sd}t|}xl||jo^||d}||\\}}} ||jo |}q7||jo|d}q7| Sq7WtddS(NiiisShould never get here(tlentAssertionError( tvalt.1texacttrangestlothitmidttltthtnode((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyt value_checks         cCs(|djo|fStt||S(N(tNoneRR(Rtcode((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR &s cCs |idS(i(tUNPACK_SEQUENCE(tc((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyt*scCs&|djo|fS||tdS(N(R'tsubclass_check(RR(((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR5s tincCs>|djo|fS|ttt|fdttdS(Ntfold(R'tCalltConsttidtFalsetidentity_check(RR(((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR@s cCsB|djo|fS|ittt|tifd|dS(NR((R't LOAD_CONSTR&R/tPassRtARG(RR(((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyREs  cCsg|djo|fSt}|ti|id|||iti|titi tidS(Ni( R'tLabelRR6R)t JUMP_IF_TRUEtCodet ROT_THREEtPOP_TOPtROT_TWO(RR(tskip((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyRKs   RcBseZdZdZRS(s;Extended expression builder with support for meta-functionscCstddS(Ns(backquotes are not allowed in predicates(t SyntaxError(tselfR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyt BackquoteVs(t__name__t __module__t__doc__R@(((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyRSscs%\fd}t|S(s0Declare a meta-function and its argument parserscsax>ti|idD]&}t|tptdqqW|ti|ft<|S(Nis1Meta-functions cannot have packed-tuple arguments(tinspecttgetargst func_codet isinstancet basestringt TypeErrort getargspectmeta_functions(tframetnametfunct old_locals(tstubtparsers(s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pytcallback^s(R(RPRQRR((RPRQs9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR[s tCriteriaBuildercBseZeZeiiZdZdZxWe eD]IZ e di o2e de di joee e e s<=s>=s=>s=s!=s==tissis notc Csj|\\}}|dg|dj}t|i|}}t|i|}}t|to/||ijo|||i|}}}nt|to|djp |djo7t||i}|dj ot||djSqN|djp |djo tt ||i|djSt t |t ||iSnt t|||ffS(Ns!=s<>R-snot inResis not(R RTRGR0t _mirror_opst compileIntvalueR't maybe_invertt compileIstTestRt InequalityRXtCompare( R?tinitExprt.2RZtothertold_optlefttrighttcond((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyRms     #cCs4ttg}|D]}|t||q~tS(N(treducet intersectR tTrue(R?titemst_[1]R((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pytAndscCstt|i|S(N(tOrElsetmapR_(R?Rx((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pytOrsc Csti|i}||}t|to1|itjo!|it|i||||Stt |t ||g}|D]%\} } ||| || fq~|o |||o ||S(N( R t__get__RTRGR0RhRKt apply_metaRXR/R|( R?RNRYtkwt star_nodet dstar_nodetbttargetRytktv((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pytCallFuncs  Ecs|\}\}} } } fd} h} g}d}x|D]w}|djoi| |scCstt||S(N(RkR (RR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pytcompileInIsTypeBscBseZdZdZdZdZdZedZedZ ee i i Z dZ dZd Zd Zd Zd Zd ZRS(s;A dispatching engine that builds trees using bitmap indexescCseg|_h|_tt|i|tg}|iD]}||t|fq9~|_dS(N( t signaturest all_exprstsuperRRWtdictRtLocalRU(R?tdispRyR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyRWLs  c Cstt||}||ijot|i}|ii|g}|i}xt||D]\}}}||jo5d||x7t||iD]#\}}t|t||VqWdS(N(RRRR(tobRRR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyttests_for_tuples cCstS(s(Is `expr` safe to evaluate in any order?(R2(R((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyRscCs t|iS(N(RR(R((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyttestable_criterionscCstS((Rw(R((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR+scCstS((Rw(R((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR+scCst|i|i|it}t||}|dj o=|io3t||i|id|}t ||}nt |i ||i |i S(Ni(RSRUt localdictt globaldictt __builtins__R R'RRRvtRuletbodyt actiontypetsequence(Rt predicatetctxRRR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyt _parse_strings  cOsttt||||S((tcompileIsXCallRGR (RRRYR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR+scOsttt||||S((R t issubclassR(RRRYR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR+scCs|pVt|djpCt|dt p.t|dtp|dj p |dj o/ttt||t|i||S|\}}t||t t t t |i S(Niii(RRGR0R'RXR/ttupleRxRkRR|Rt _yield_tuplesRh(RNttestRYRRRRtseq((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR  s /., ccsMt|tjo1x3|D]"}xt|D] }|Vq-WqWn|VdS(N(ttypeR R (Rti1ti2((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyR +s sWexpr in Call and expr.func in Const and (expr.func.value is type) and len(expr.args)==1cCs tt|idt|S(Ni(RkR RYtistype(RR((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pytcompileTypeIsX8s((Ytpeak.util.assemblertcoreRtcriteriatindexingtcodegenRRRRtpeak.util.decoratorsRRRttypesR R t ast_builderR R RDt__all__tabstractRR&tnodetypeR'R t_unpackt TryExcepttSuiteR9tDUP_TOPR6R:R;t BINARY_SUBSCRR<R0RR/R5R,RRmR3RRRRKRRSRjRiRXtwhenRgtobjectRRRRtEngineRRtbitmap_index_typeRRRRt NameErrorRRRRRR RRRRt parse_ruleRHRRGR R R R(((s9/usr/lib/python2.6/site-packages/peak/rules/predicates.pyts    "      3 $    !      \