Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/compiler/
Upload File :
Current File : //usr/lib/python2.7/compiler/symbols.pyc


|_c@s=dZddlmZddlmZmZmZmZmZm	Z	ddl
mZddlZddl
Z
dZdddYZd	efd
YZdefd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_EXPLICTtSC_FREEtSC_CELLt
SC_UNKNOWN(tmangleNitScopecBseZddZdZdZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZdZRS(cCs||_||_i|_i|_i|_i|_i|_i|_g|_d|_
d|_d|_|dk	rx>t
t|D]'}||dkr|||_PqqWndS(Nt_(tnametmoduletdefstusestglobalstparamstfreestcellstchildrentNonetnestedt	generatortklasstrangetlen(tselfR
RRti((s&/usr/lib/python2.7/compiler/symbols.pyt__init__s"												
cCsd|jj|jfS(Ns<%s: %s>(t	__class__t__name__R
(R((s&/usr/lib/python2.7/compiler/symbols.pyt__repr__%scCs#|jdkr|St||jS(N(RRR(RR
((s&/usr/lib/python2.7/compiler/symbols.pyR(scCsd|j|j|<dS(Ni(RR(RR
((s&/usr/lib/python2.7/compiler/symbols.pytadd_def-scCsd|j|j|<dS(Ni(R
R(RR
((s&/usr/lib/python2.7/compiler/symbols.pytadd_use0scCsy|j|}||jks0||jkr0n||jkrXtd||jfnd|j|<|jj|dS(Ns %s in %s is global and parameteri(	RR
RRtSyntaxErrorR
RRR(RR
((s&/usr/lib/python2.7/compiler/symbols.pyt
add_global3s
cCs-|j|}d|j|<d|j|<dS(Ni(RRR(RR
((s&/usr/lib/python2.7/compiler/symbols.pyt	add_param=s
cCs@i}|j|j|j|j|j|j|jS(N(tupdateRR
Rtkeys(Rtd((s&/usr/lib/python2.7/compiler/symbols.pyt	get_namesBs
cCs|jj|dS(N(Rtappend(Rtchild((s&/usr/lib/python2.7/compiler/symbols.pyt	add_childIscCs|jS(N(R(R((s&/usr/lib/python2.7/compiler/symbols.pytget_childrenLscCstj|jI|jrdp"dIJtjdI|jIJtjdI|jIJtjdI|jIJtjdI|jIJtjdI|jIJdS(NRts
	globals: s	cells: s	defs: s	uses: s	frees:(	tsyststderrR
RRRRR
R(R((s&/usr/lib/python2.7/compiler/symbols.pytDEBUGOs%cCsy||jkrtS||jkr&tS||jkr9tS|jrd||jks`||jkrdt	S|jrqt
StSdS(sbReturn scope of name.

        The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
        N(RRRRRRRRR
RRR(RR
((s&/usr/lib/python2.7/compiler/symbols.pyt
check_nameWs'	cCsr|js
dSi}|j|jxB|jjD]1}||jkr3||jkr3d||<q3q3W|jS(Ni((RR$RR
R%RR(RtfreeR
((s&/usr/lib/python2.7/compiler/symbols.pyt
get_free_varsis	cCsQxJ|jD]?}|j}|j|}x|D]}|j|q2Wq
WdS(N(RR2t	add_freestforce_global(RR)RRR
((s&/usr/lib/python2.7/compiler/symbols.pythandle_childrenss

cCsfd|j|<||jkr)|j|=nx6|jD]+}|j|tkr3|j|q3q3WdS(sForce name to be global in scope.

        Some child of the current node had a free reference to name.
        When the child was processed, it was labelled a free
        variable.  Now that all its enclosing scope have been
        processed, the name is known to be a global or builtin.  So
        walk back down the child chain and set the name to be global
        rather than free.

        Be careful to stop if a child does not think the name is
        free.
        iN(RRRR0RR4(RR
R)((s&/usr/lib/python2.7/compiler/symbols.pyR4zs


cCsg}x|D]}|j|}|jr|tksR|tksRt|trbd|j|<q|tkr~|j|qt|t	r|t
krd|j|<q|tkr|j|qq
|t
krd|j|<q
|tkr
|j|q
q
W|S(sProcess list of free vars from nested scope.

        Returns a list of names that are either 1) declared global in the
        parent or 2) undefined in a top-level parent.  In either case,
        the nested scope should treat them as globals.
        i(
R0RRRt
isinstancet
ClassScopeRRR(t
FunctionScopeRRR(Rtnamest
child_globalsR
tsc((s&/usr/lib/python2.7/compiler/symbols.pyR3s$
	cCs
|jjS(N(RR%(R((s&/usr/lib/python2.7/compiler/symbols.pyt
get_cell_varssN(Rt
__module__RRRRRR R"R#R'R*R+R/R0R2R5R4R3R<(((s&/usr/lib/python2.7/compiler/symbols.pyRs"					
							
			tModuleScopecBseZejZdZRS(cCs|jd|dS(Ntglobal(t_ModuleScope__super_init(R((s&/usr/lib/python2.7/compiler/symbols.pyRs(RR=RRR@(((s&/usr/lib/python2.7/compiler/symbols.pyR>s	R8cBseZRS((RR=(((s&/usr/lib/python2.7/compiler/symbols.pyR8stGenExprScopecBs,eZejZdZddZdZRS(icCs@|j}|jd7_|jd||||jddS(Nisgenerator expression<%d>s.0(t_GenExprScope__countert_GenExprScope__super_initR#(RRRR((s&/usr/lib/python2.7/compiler/symbols.pyRs	cCstj|}|S(N(RR'(RR%((s&/usr/lib/python2.7/compiler/symbols.pyR'sN(RR=RRRCRBRR'(((s&/usr/lib/python2.7/compiler/symbols.pyRAs	tLambdaScopecBs#eZejZdZddZRS(icCs3|j}|jd7_|jd|||dS(Nis	lambda.%d(t_LambdaScope__countert_LambdaScope__super_init(RRRR((s&/usr/lib/python2.7/compiler/symbols.pyRs	N(RR=RRRFRER(((s&/usr/lib/python2.7/compiler/symbols.pyRDs	R7cBseZejZdZRS(cCs|j|||dS(N(t_ClassScope__super_init(RR
R((s&/usr/lib/python2.7/compiler/symbols.pyRs(RR=RRRG(((s&/usr/lib/python2.7/compiler/symbols.pyR7s	t
SymbolVisitorcBseZdZdZeZdZdZdZdZdZ	ddZ
d	Zd
ZdZ
ddZd
ZdZdZdZdZddZddZddZddZdZejejejfZdZdZRS(cCsi|_d|_dS(N(tscopesRR(R((s&/usr/lib/python2.7/compiler/symbols.pyRs	cCs2t}|_|j|<|j|j|dS(N(R>RRItvisittnode(RRKtscope((s&/usr/lib/python2.7/compiler/symbols.pytvisitModulescCs|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
tdefaultsR8RRRR6RIt_do_argstargnamestcodethandle_free_vars(RRKtparenttnRL((s&/usr/lib/python2.7/compiler/symbols.pyt
visitFunctions	
cCs|t|j|j}|js<t|ts<t|trHd|_n||j|<|j|j||j	||dS(Ni(
RARRRR6R8RIRJRRRS(RRKRTRL((s&/usr/lib/python2.7/compiler/symbols.pytvisitGenExprs
cCs;x!|jD]}|j||q
W|j|j|dS(N(tqualsRJtexpr(RRKRLtgenfor((s&/usr/lib/python2.7/compiler/symbols.pytvisitGenExprInnerscCsQ|j|j|d|j|j|x!|jD]}|j||q3WdS(Ni(RJtassigntitertifs(RRKRLtif_((s&/usr/lib/python2.7/compiler/symbols.pytvisitGenExprForscCs|j|j|dS(N(RJttest(RRKRL((s&/usr/lib/python2.7/compiler/symbols.pytvisitGenExprIfsicCs|s
tx!|jD]}|j||qWt|j|j}|js^t|trjd|_n||j	|<|j
||j|j|j||j
||dS(Ni(tAssertionErrorRORJRDRRRR6R8RIRPRQRRRS(RRKRTR\RURL((s&/usr/lib/python2.7/compiler/symbols.pytvisitLambda	s

cCsJxC|D];}t|tjkr5|j||q|j|qWdS(N(ttypettypest	TupleTypeRPR#(RRLtargsR
((s&/usr/lib/python2.7/compiler/symbols.pyRPs
cCs|j||jdS(N(R*R5(RRLRT((s&/usr/lib/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
tbasesRJR7RRR6R8tdocRRIRRRRS(RRKRTRURLtprev((s&/usr/lib/python2.7/compiler/symbols.pyt
visitClass$s

		cCs-|r|j|jn|j|jdS(N(RR
R (RRKRLR\((s&/usr/lib/python2.7/compiler/symbols.pyt	visitName;scCs_|j|j|d|j|j||j|j||jr[|j|j|ndS(Ni(RJR\tlisttbodytelse_(RRKRL((s&/usr/lib/python2.7/compiler/symbols.pytvisitForCs
	cCsCx<|jD]1\}}|dkr(q
n|j|p7|q
WdS(Nt*(R9R(RRKRLR
tasname((s&/usr/lib/python2.7/compiler/symbols.pyt	visitFromJscCsYxR|jD]G\}}|jd}|dkr>|| }n|j|pM|q
WdS(Nt.i(R9tfindR(RRKRLR
RtR((s&/usr/lib/python2.7/compiler/symbols.pytvisitImportPs

cCs%x|jD]}|j|q
WdS(N(R9R"(RRKRLR
((s&/usr/lib/python2.7/compiler/symbols.pytvisitGlobalWscCs>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/lib/python2.7/compiler/symbols.pytvisitAssign[s
icCs|j|jdS(N(RR
(RRKRLR\((s&/usr/lib/python2.7/compiler/symbols.pytvisitAssNamelscCs|j|j|ddS(Ni(RJRY(RRKRLR\((s&/usr/lib/python2.7/compiler/symbols.pytvisitAssAttroscCsA|j|j|dx$|jD]}|j||dq WdS(Ni(RJRYtsubs(RRKRLR\RU((s&/usr/lib/python2.7/compiler/symbols.pytvisitSubscriptrscCs^|j|j|d|jr8|j|j|dn|jrZ|j|j|dndS(Ni(RJRYtlowertupper(RRKRLR\((s&/usr/lib/python2.7/compiler/symbols.pyt
visitSlicews
		cCsX|j|j|t|jtjrA|j|j|dn|j|j|dS(Ni(RJRKR6RtNameRY(RRKRL((s&/usr/lib/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/lib/python2.7/compiler/symbols.pytvisitIfs		cCs d|_|j|j|dS(Ni(RRJR(RRKRL((s&/usr/lib/python2.7/compiler/symbols.pyt
visitYields	( RR=RRMtvisitExpressionRVRWR[R`RbRdRPRSRmRnRrRuRxRyR{R|R}RRRRft
StringTypetIntTypet	FloatTypeRRR(((s&/usr/lib/python2.7/compiler/symbols.pyRHs4																
	
cCst|t|kS(N(tsorted(tl1tl2((s&/usr/lib/python2.7/compiler/symbols.pytlist_eqst__main__(t	parseFiletwalkcCsTgg|jD]}|j^qD]*}|jdpG|jds&|^q&S(Ns_[Rv(tget_symbolstget_namet
startswith(tsymsts((s&/usr/lib/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/lib/python2.7/compiler/symbols.pyt<module>sj.
		
	
	
!