ofc@s=dZddlmZddlmZmZmZmZmZm Z ddl m Z ddl Z ddl Z dZdddYZd efd YZd efd YZd efdYZdefdYZdefdYZdddYZdZedkr9ddl Z ddlmZmZddlZdZxe jdD]ZeGHeeZej Z!ej"eje!edZ#ee#Z$eeZ%eZ&ee%e&e&j'e%jZ(ee$e(s"HdGeGHe)e$GHe)e(GHe j*dniZ+e+j,e&j'e+e%=e+j-Z'[+xe#j.D]Z&e&j/r[ge'D]!Z0e0j1e&j2krte0^qtZ3e4e3dkrdGe&j2GHq.eee&j5e3djs.e&j2GHe)ee&j5GHe)e3djGHe j*dq.q[q[Wq`WndS( sModule symbol-table generatori(tast(tSC_LOCALtSC_GLOBAL_IMPLICITtSC_GLOBAL_EXPLICITtSC_FREEtSC_CELLt SC_UNKNOWN(tmangleNitScopecBseZddZdZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZRS(cCs||_||_i|_i|_i|_i|_i|_i|_g|_d|_ d|_ d|_ |dk rx>t t|D]'}||dkr|||_ PqqWndS(Nt_(tnametmoduletdefstusestglobalstparamstfreestcellstchildrentNonetnestedt generatortklasstrangetlen(tselfR R Rti((s(/usr/lib64/python2.7/compiler/symbols.pyt__init__s"              cCsd|jj|jfS(Ns<%s: %s>(t __class__t__name__R (R((s(/usr/lib64/python2.7/compiler/symbols.pyt__repr__%scCs#|jdkr|St||jS(N(RRR(RR ((s(/usr/lib64/python2.7/compiler/symbols.pyR(scCsd|j|j|s R8cBseZRS((RR=(((s(/usr/lib64/python2.7/compiler/symbols.pyR8st GenExprScopecBs,eZejZdZddZdZRS(icCs@|j}|jd7_|jd||||jddS(Nisgenerator expression<%d>s.0(t_GenExprScope__countert_GenExprScope__super_initR#(RR RR((s(/usr/lib64/python2.7/compiler/symbols.pyRs cCstj|}|S(N(RR'(RR%((s(/usr/lib64/python2.7/compiler/symbols.pyR'sN(RR=RRRCRBRR'(((s(/usr/lib64/python2.7/compiler/symbols.pyRAs  t LambdaScopecBs#eZejZdZddZRS(icCs3|j}|jd7_|jd|||dS(Nis lambda.%d(t_LambdaScope__countert_LambdaScope__super_init(RR RR((s(/usr/lib64/python2.7/compiler/symbols.pyRs N(RR=RRRFRER(((s(/usr/lib64/python2.7/compiler/symbols.pyRDs R7cBseZejZdZRS(cCs|j|||dS(N(t_ClassScope__super_init(RR R ((s(/usr/lib64/python2.7/compiler/symbols.pyRs(RR=RRRG(((s(/usr/lib64/python2.7/compiler/symbols.pyR7s t SymbolVisitorcBseZdZdZeZdZdZdZdZdZ ddZ d Z d Z d Z dd Zd ZdZdZdZdZddZddZddZddZdZejejejfZdZdZRS(cCsi|_d|_dS(N(tscopesRR(R((s(/usr/lib64/python2.7/compiler/symbols.pyRs cCs2t}|_|j|<|j|j|dS(N(R>R RItvisittnode(RRKtscope((s(/usr/lib64/python2.7/compiler/symbols.pyt visitModulescCs|jr|j|j|n|j|jx!|jD]}|j||q9Wt|j|j|j}|jst |trd|_n||j |<|j ||j |j|j ||j||dS(Ni(t decoratorsRJRR tdefaultsR8R RRR6RIt_do_argstargnamestcodethandle_free_vars(RRKtparenttnRL((s(/usr/lib64/python2.7/compiler/symbols.pyt visitFunctions   cCs|t|j|j}|js<t|ts<t|trHd|_n||j|<|j|j||j ||dS(Ni( RAR RRR6R8RIRJRRRS(RRKRTRL((s(/usr/lib64/python2.7/compiler/symbols.pyt visitGenExprs  cCs;x!|jD]}|j||q W|j|j|dS(N(tqualsRJtexpr(RRKRLtgenfor((s(/usr/lib64/python2.7/compiler/symbols.pytvisitGenExprInnerscCsQ|j|j|d|j|j|x!|jD]}|j||q3WdS(Ni(RJtassigntitertifs(RRKRLtif_((s(/usr/lib64/python2.7/compiler/symbols.pytvisitGenExprForscCs|j|j|dS(N(RJttest(RRKRL((s(/usr/lib64/python2.7/compiler/symbols.pytvisitGenExprIfsicCs| s tx!|jD]}|j||qWt|j|j}|js^t|trjd|_n||j |<|j ||j |j|j ||j ||dS(Ni(tAssertionErrorRORJRDR RRR6R8RIRPRQRRRS(RRKRTR\RURL((s(/usr/lib64/python2.7/compiler/symbols.pyt visitLambda s   cCsJxC|D];}t|tjkr5|j||q|j|qWdS(N(ttypettypest TupleTypeRPR#(RRLtargsR ((s(/usr/lib64/python2.7/compiler/symbols.pyRPs cCs|j||jdS(N(R*R5(RRLRT((s(/usr/lib64/python2.7/compiler/symbols.pyRS s cCs|j|jx!|jD]}|j||qWt|j|j}|jsat|trmd|_n|j dk r|jdn|jd||j |<|j }|j|_ |j|j |||_ |j||dS(Nit__doc__R=(RR tbasesRJR7R RR6R8tdocRRIRRRRS(RRKRTRURLtprev((s(/usr/lib64/python2.7/compiler/symbols.pyt visitClass$s      cCs-|r|j|jn|j|jdS(N(RR R (RRKRLR\((s(/usr/lib64/python2.7/compiler/symbols.pyt visitName;scCs_|j|j|d|j|j||j|j||jr[|j|j|ndS(Ni(RJR\tlisttbodytelse_(RRKRL((s(/usr/lib64/python2.7/compiler/symbols.pytvisitForCs  cCsCx<|jD]1\}}|dkr(q n|j|p7|q WdS(Nt*(R9R(RRKRLR tasname((s(/usr/lib64/python2.7/compiler/symbols.pyt visitFromJs cCsYxR|jD]G\}}|jd}|dkr>|| }n|j|pM|q WdS(Nt.i(R9tfindR(RRKRLR RtR((s(/usr/lib64/python2.7/compiler/symbols.pyt visitImportPs   cCs%x|jD]}|j|q WdS(N(R9R"(RRKRLR ((s(/usr/lib64/python2.7/compiler/symbols.pyt visitGlobalWscCs>x$|jD]}|j||dq W|j|j|dS(s.Propagate assignment flag down to child nodes. The Assign node doesn't itself contains the variables being assigned to. Instead, the children in node.nodes are visited with the assign flag set to true. When the names occur in those nodes, they are marked as defs. Some names that occur in an assignment target are not bound by the assignment, e.g. a name occurring inside a slice. The visitor handles these nodes specially; they do not propagate the assign flag to their children. iN(tnodesRJRY(RRKRLRU((s(/usr/lib64/python2.7/compiler/symbols.pyt visitAssign[s icCs|j|jdS(N(RR (RRKRLR\((s(/usr/lib64/python2.7/compiler/symbols.pyt visitAssNamelscCs|j|j|ddS(Ni(RJRY(RRKRLR\((s(/usr/lib64/python2.7/compiler/symbols.pyt visitAssAttroscCsA|j|j|dx$|jD]}|j||dq WdS(Ni(RJRYtsubs(RRKRLR\RU((s(/usr/lib64/python2.7/compiler/symbols.pytvisitSubscriptrscCs^|j|j|d|jr8|j|j|dn|jrZ|j|j|dndS(Ni(RJRYtlowertupper(RRKRLR\((s(/usr/lib64/python2.7/compiler/symbols.pyt visitSlicews   cCsX|j|j|t|jtjrA|j|j|dn|j|j|dS(Ni(RJRKR6RtNameRY(RRKRL((s(/usr/lib64/python2.7/compiler/symbols.pytvisitAugAssign~scCsxv|jD]k\}}t|tjrUt|j|jkrU|jsRq qRqUn|j|||j||q W|jr|j|j|ndS(N( ttestsR6RtConstRetvaluet _const_typesRJRq(RRKRLRaRp((s(/usr/lib64/python2.7/compiler/symbols.pytvisitIfs   cCs d|_|j|j|dS(Ni(RRJR(RRKRL((s(/usr/lib64/python2.7/compiler/symbols.pyt visitYields ( RR=RRMtvisitExpressionRVRWR[R`RbRdRPRSRmRnRrRuRxRyR{R|R}RRRRft StringTypetIntTypet FloatTypeRRR(((s(/usr/lib64/python2.7/compiler/symbols.pyRHs4                      cCst|t|kS(N(tsorted(tl1tl2((s(/usr/lib64/python2.7/compiler/symbols.pytlist_eqst__main__(t parseFiletwalkcCsTgg|jD]}|j^qD]*}|jdpG|jds&|^q&S(Ns_[Rv(t get_symbolstget_namet startswith(tsymsts((s(/usr/lib64/python2.7/compiler/symbols.pyR's,itexectoopstskippingi(((6RitcompilerRtcompiler.constsRRRRRRt compiler.miscRRfR-t MANGLE_LENRR>R8RARDR7RHRRRRtsymtableR'targvtfiletopentftreadtbuftcloseRt mod_namesttreeRRItnames2RtexitR&R$tvaluesRt is_namespaceR;R RtlRt get_namespace(((s(/usr/lib64/python2.7/compiler/symbols.pytsj.                     !