B 7 @sJddlZddlmZmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZddlZdddddgZddZGd d d ZeZGd ddeZGd ddeZGd ddeZGdddeZedkrFddlZddlZeejdZeZ WdQRXee ej!"ejdddZ#x0e#$D]$Z%e#&e%Z'e(e'e')e'*qWdS)N)USE DEF_GLOBAL DEF_LOCAL DEF_PARAM DEF_IMPORT DEF_BOUND DEF_ANNOT SCOPE_OFF SCOPE_MASKFREELOCALGLOBAL_IMPLICITGLOBAL_EXPLICITCELLsymtable SymbolTableClassFunctionSymbolcCst|||}t||S)N) _symtabler_newSymbolTable)codefilenameZ compile_typetopr+/opt/alt/python37/lib/python3.7/symtable.pyr sc@s$eZdZddZddZddZdS)SymbolTableFactorycCst|_dS)N)weakrefZWeakValueDictionary_SymbolTableFactory__memo)selfrrr__init__szSymbolTableFactory.__init__cCs6|jtjkrt||S|jtjkr,t||St||S)N)typer TYPE_FUNCTIONr TYPE_CLASSrr)rtablerrrrnews     zSymbolTableFactory.newcCs8||f}|j|d}|dkr4|||}|j|<|S)N)rgetr%)rr$rkeyobjrrr__call__s zSymbolTableFactory.__call__N)__name__ __module__ __qualname__r r%r)rrrrrsrc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS) rcCs||_||_i|_dS)N)_table _filename_symbols)rZ raw_tablerrrrr 'szSymbolTable.__init__cCsN|jtkrd}n d|jj}|jjdkr6d||jSd||jj|jSdS)Nz%s globalz<{0}SymbolTable for module {1}>z<{0}SymbolTable for {1} in {2}>) __class__rr*r-nameformatr.)rkindrrr__repr__,s   zSymbolTable.__repr__cCs:|jjtjkrdS|jjtjkr$dS|jjtjkr6dSdS)NmoduleZfunctionclass)r-r!rZ TYPE_MODULEr"r#)rrrrget_type9szSymbolTable.get_typecCs|jjS)N)r-id)rrrrget_idCszSymbolTable.get_idcCs|jjS)N)r-r3)rrrrget_nameFszSymbolTable.get_namecCs|jjS)N)r-lineno)rrrr get_linenoIszSymbolTable.get_linenocCst|jjtjkS)N)boolr-r!rr")rrrr is_optimizedLszSymbolTable.is_optimizedcCs t|jjS)N)r?r-nested)rrrr is_nestedOszSymbolTable.is_nestedcCs t|jjS)N)r?r-children)rrrr has_childrenRszSymbolTable.has_childrencCsdS)NFr)rrrrhas_execUszSymbolTable.has_execcCs |jjS)N)r-symbolskeys)rrrrget_identifiersYszSymbolTable.get_identifierscCsD|j|}|dkr@|jj|}||}t|||}|j|<|S)N)r/r&r-rF_SymbolTable__check_childrenr)rr3Zsymflags namespacesrrrlookup\s    zSymbolTable.lookupcsfddDS)Ncsg|]}|qSr)rL).0ident)rrr esz+SymbolTable.get_symbols..)rH)rr)rr get_symbolsdszSymbolTable.get_symbolscsfddjjDS)Ncs"g|]}|jkrt|jqSr)r3rr.)rMst)r3rrrrOhsz0SymbolTable.__check_children..)r-rC)rr3r)r3rrZ__check_childrengs zSymbolTable.__check_childrencsfddjjDS)Ncsg|]}t|jqSr)rr.)rMrQ)rrrrOmsz,SymbolTable.get_children..)r-rC)rr)rr get_childrenls zSymbolTable.get_childrenN)r*r+r,r r6r9r;r<r>r@rBrDrErHrLrPrIrRrrrrr%s  c@sDeZdZdZdZdZdZddZddZddZ dd Z d d Z dS) rNcstfddDS)Nc3s"|]}jj|r|VqdS)N)r-rF)rMrN)r test_funcrr zsz-Function.__idents_matching..)tuplerH)rrSr)rrSrZ__idents_matchingyszFunction.__idents_matchingcCs |jdkr|dd|_|jS)NcSs|t@S)N)r)xrrrz)Function.get_parameters..)_Function__params_Function__idents_matching)rrrrget_parameters}s zFunction.get_parameterscs0|jdkr*ttffdd}|||_|jS)Ncs|t?t@kS)N)r r )rV)locsrrrWrXz%Function.get_locals..)_Function__localsr rrZ)rtestr)r\r get_localss    zFunction.get_localscs0|jdkr*ttffdd}|||_|jS)Ncs|t?t@kS)N)r r )rV)globrrrWrXz&Function.get_globals..)_Function__globalsr rrZ)rr^r)r`r get_globalss    zFunction.get_globalscCs$|jdkrdd}|||_|jS)NcSs|t?t@tkS)N)r r r )rVrrrrWrXz$Function.get_frees..)_Function__freesrZ)ris_freerrr get_freess  zFunction.get_frees) r*r+r,rYr]rcrarZr[r_rbrerrrrrqsc@seZdZdZddZdS)rNcCs:|jdkr4i}x|jjD]}d||j<qWt||_|jS)N)_Class__methodsr-rCr3rU)rdrQrrr get_methodss   zClass.get_methods)r*r+r,rgrirrrrrsc@seZdZd ddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZdS)!rNcCs(||_||_|t?t@|_|p d|_dS)Nr) _Symbol__name_Symbol__flagsr r _Symbol__scope_Symbol__namespaces)rr3rJrKrrrr szSymbol.__init__cCs d|jS)Nz)r4rj)rrrrr6szSymbol.__repr__cCs|jS)N)rj)rrrrr<szSymbol.get_namecCst|jtj@S)N)r?rkrr)rrrr is_referencedszSymbol.is_referencedcCst|jt@S)N)r?rkr)rrrr is_parameterszSymbol.is_parametercCst|jttfkS)N)r?rlr r)rrrr is_globalszSymbol.is_globalcCst|jtkS)N)r?rlr)rrrris_declared_globalszSymbol.is_declared_globalcCst|jttfkS)N)r?rlr r)rrrris_localszSymbol.is_localcCst|jt@S)N)r?rkr)rrrr is_annotatedszSymbol.is_annotatedcCst|jtkS)N)r?rlr )rrrrrdszSymbol.is_freecCst|jt@S)N)r?rkr)rrrr is_importedszSymbol.is_importedcCst|jt@S)N)r?rkr)rrrr is_assignedszSymbol.is_assignedcCs t|jS)N)r?rm)rrrr is_namespaces zSymbol.is_namespacecCs|jS)N)rm)rrrrget_namespacesszSymbol.get_namespacescCs t|jdkrtd|jdS)Nrfz$name is bound to multiple namespacesr)lenrm ValueError)rrrr get_namespaceszSymbol.get_namespace)N)r*r+r,r r6r<rnrorprqrrrsrdrtrurvrwrzrrrrrs  __main__rfexec)+rrrrrrrrr r r r r rrr__all__rrrobjectrrrrr*ossysopenargvfreadsrcpathsplitmodrHrNrLinfoprintrrrvrrrrs$@L& C