404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.217.27.209: ~ $
3

g�wU5�@s ddlmZGdd�de�ZdS)�)�c_astc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdldd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1dmd_d`�Z2dadb�Z3gfdcdd�Z4dedf�Z5dgdh�Z6didj�Z7dkS)n�
CGeneratorz� Uses the same visitor pattern as c_ast.NodeVisitor, but modified to
        return a value from each visit method, using string accumulation in
        generic_visit.
    cCs
d|_dS)N�)�indent_level)�self�r�!/usr/lib/python3.6/c_generator.py�__init__szCGenerator.__init__cCs
d|jS)N� )r)rrrr�_make_indentszCGenerator._make_indentcCsd|jj}t|||j�|�S)NZvisit_)�	__class__�__name__�getattr�
generic_visit)r�node�methodrrr�visitszCGenerator.visitcs,|dkrdSdj�fdd�|j�D��SdS)N�c3s|]\}}�j|�VqdS)N)r)�.0Zc_name�c)rrr�	<genexpr>#sz+CGenerator.generic_visit.<locals>.<genexpr>)�joinZchildren)rrr)rrrszCGenerator.generic_visitcCs|jS)N)�value)r�nrrr�visit_Constant%szCGenerator.visit_ConstantcCs|jS)N)�name)rrrrr�visit_ID(szCGenerator.visit_IDcCs$|j|j�}|d|j|j�dS)N�[�])�_parenthesize_unless_simplerrZ	subscript)rrZarrrefrrr�visit_ArrayRef+szCGenerator.visit_ArrayRefcCs"|j|j�}||j|j|j�S)N)rr�typerZfield)rrZsrefrrr�visit_StructRef/szCGenerator.visit_StructRefcCs$|j|j�}|d|j|j�dS)N�(�))rrr�args)rrZfrefrrr�visit_FuncCall3szCGenerator.visit_FuncCallcCs\|j|j�}|jdkrd|S|jdkr0d|S|jdkrJd|j|j�Sd|j|fSdS)Nzp++z%s++zp--z%s--Zsizeofz
sizeof(%s)z%s%s)r�expr�opr)rrZoperandrrr�
visit_UnaryOp7s


zCGenerator.visit_UnaryOpcs<�j|j�fdd��}�j|j�fdd��}d||j|fS)Ncs�j|�S)N)�_is_simple_node)�d)rrr�<lambda>Fsz+CGenerator.visit_BinaryOp.<locals>.<lambda>cs�j|�S)N)r*)r+)rrrr,Hsz%s %s %s)�_parenthesize_if�left�rightr()rrZlval_str�rval_strr)rr�visit_BinaryOpDs
zCGenerator.visit_BinaryOpcCs*|j|jdd��}d|j|j�|j|fS)NcSst|tj�S)N)�
isinstancer�
Assignment)rrrrr,Nsz-CGenerator.visit_Assignment.<locals>.<lambda>z%s %s %s)r-ZrvaluerZlvaluer()rrr0rrr�visit_AssignmentKs
zCGenerator.visit_AssignmentcCsdj|j�S)Nr
)r�names)rrrrr�visit_IdentifierTypeQszCGenerator.visit_IdentifierTypecCsJt|tj�rd|j|�dSt|tj�r<d|j|�dS|j|�SdS)N�{�}r#r$)r2rZInitListr�ExprList)rrrrr�_visit_exprTs
zCGenerator._visit_exprFcCsL|r
|jn|j|�}|jr.|d|j|j�7}|jrH|d|j|j�7}|S)Nz : z = )r�_generate_declZbitsizer�initr:)rr�no_type�srrr�
visit_Decl\szCGenerator.visit_DeclcsL�j|jd�}t|j�dkrH|ddj�fdd�|jdd�D��7}|S)Nrrz, c3s|]}�j|dd�VqdS)T)r=N)r?)r�decl)rrrrisz,CGenerator.visit_DeclList.<locals>.<genexpr>)r�decls�lenr)rrr>r)rr�visit_DeclListfs
zCGenerator.visit_DeclListcCs2d}|jr|dj|j�d7}||j|j�7}|S)Nrr
)�storager�_generate_typer!)rrr>rrr�
visit_Typedefms
zCGenerator.visit_TypedefcCs(d|j|j�d}|d|j|j�S)Nr#r$r
)rEZto_typerr')rrr>rrr�
visit_CastsszCGenerator.visit_CastcCs.g}x|jD]}|j|j|��qWdj|�S)Nz, )�exprs�appendr:r)rr�visited_subexprsr'rrr�visit_ExprListwszCGenerator.visit_ExprListcCs.g}x|jD]}|j|j|��qWdj|�S)Nz, )rHrIr:r)rrrJr'rrr�visit_InitList}szCGenerator.visit_InitListcCs�d}|jr|d|j7}|jr�|d7}xXt|jj�D]H\}}||j7}|jr`|d|j|j�7}|t|jj�dkr4|d7}q4W|d7}|S)N�enumr
z {z = rz, r8)r�values�	enumerateZenumeratorsrrrB)rrr>�iZ
enumeratorrrr�
visit_Enum�s
zCGenerator.visit_Enumcsj�j|j�}d�_�j|j�}|jrVdj�fdd�|jD��}|d|d|dS|d|dSdS)Nrz;
c3s|]}�j|�VqdS)N)r)r�p)rrrr�sz+CGenerator.visit_FuncDef.<locals>.<genexpr>�
)rr@r�bodyZparam_declsr)rrr@rTZknrdeclsr)rr�
visit_FuncDef�szCGenerator.visit_FuncDefcCsFd}x<|jD]2}t|tj�r,||j|�7}q||j|�d7}qW|S)Nrz;
)�extr2rZFuncDefr)rrr>rVrrr�
visit_FileAST�szCGenerator.visit_FileASTcs`�j�d}�jd7_|jr>|dj�fdd�|jD��7}�jd8_|�j�d7}|S)Nz{
�rc3s|]}�j|�VqdS)N)�_generate_stmt)r�stmt)rrrr�sz,CGenerator.visit_Compound.<locals>.<genexpr>z}
)rrZblock_itemsr)rrr>r)rr�visit_Compound�szCGenerator.visit_CompoundcCsdS)N�;r)rrrrr�visit_EmptyStatement�szCGenerator.visit_EmptyStatementcsdj�fdd�|jD��S)Nz, c3s|]}�j|�VqdS)N)r)rZparam)rrrr�sz-CGenerator.visit_ParamList.<locals>.<genexpr>)rZparams)rrr)rr�visit_ParamList�szCGenerator.visit_ParamListcCs&d}|jr|d|j|j�7}|dS)N�returnr
r\)r'r)rrr>rrr�visit_Return�szCGenerator.visit_ReturncCsdS)Nzbreak;r)rrrrr�visit_Break�szCGenerator.visit_BreakcCsdS)Nz	continue;r)rrrrr�visit_Continue�szCGenerator.visit_ContinuecCs8|j|j�d}||j|j�d7}||j|j�7}|S)Nz ? z : )r:�cond�iftrue�iffalse)rrr>rrr�visit_TernaryOp�szCGenerator.visit_TernaryOpcCsdd}|jr||j|j�7}|d7}||j|jdd�7}|jr`||j�d7}||j|jdd�7}|S)Nzif (z)
T)�
add_indentzelse
)rcrrYrdrer)rrr>rrr�visit_If�szCGenerator.visit_IfcCs~d}|jr||j|j�7}|d7}|jr<|d|j|j�7}|d7}|jr^|d|j|j�7}|d7}||j|jdd�7}|S)Nzfor (r\r
z)
T)rg)r<rrc�nextrYrZ)rrr>rrr�	visit_For�szCGenerator.visit_ForcCs:d}|jr||j|j�7}|d7}||j|jdd�7}|S)Nzwhile (z)
T)rg)rcrrYrZ)rrr>rrr�visit_While�szCGenerator.visit_WhilecCsJd}||j|jdd�7}||j�d7}|jr>||j|j�7}|d7}|S)Nzdo
T)rgzwhile (z);)rYrZrrcr)rrr>rrr�
visit_DoWhile�szCGenerator.visit_DoWhilecCs,d|j|j�d}||j|jdd�7}|S)Nzswitch (z)
T)rg)rrcrYrZ)rrr>rrr�visit_Switch�szCGenerator.visit_SwitchcCs:d|j|j�d}x |jD]}||j|dd�7}qW|S)Nzcase z:
T)rg)rr'�stmtsrY)rrr>rZrrr�
visit_Case�szCGenerator.visit_CasecCs*d}x |jD]}||j|dd�7}qW|S)Nz	default:
T)rg)rnrY)rrr>rZrrr�
visit_Default�szCGenerator.visit_DefaultcCs|jd|j|j�S)Nz:
)rrYrZ)rrrrr�visit_Label�szCGenerator.visit_LabelcCsd|jdS)Nzgoto r\)r)rrrrr�
visit_Goto�szCGenerator.visit_GotocCsdS)Nz...r)rrrrr�visit_EllipsisParam�szCGenerator.visit_EllipsisParamcCs|j|d�S)N�struct)�_generate_struct_union)rrrrr�visit_StructszCGenerator.visit_StructcCs|j|j�S)N)rEr!)rrrrr�visit_TypenameszCGenerator.visit_TypenamecCs|j|d�S)N�union)ru)rrrrr�visit_UnionszCGenerator.visit_UnioncCsfd}xH|jD]>}t|tj�r,|d|j7}qt|tj�r|d|jd7}qW|d|j|j�7}|S)Nr�.rrz = )rr2r�ID�Constantrrr')rrr>rrrr�visit_NamedInitializersz!CGenerator.visit_NamedInitializercCs
|j|�S)N)rE)rrrrr�visit_FuncDeclszCGenerator.visit_FuncDeclcCs�|d|jpd}|jr~|d7}||j�7}|jd7_|d7}x|jD]}||j|�7}qJW|jd8_||j�d7}|S)ze Generates code for structs and unions. name should be either
            'struct' or union.
        r
rrSrXz{
r8)rrArrrY)rrrr>r@rrrrusz!CGenerator._generate_struct_unioncCs�t|�}|r|jd7_|j�}|r4|jd8_|tjtjtjtjtjtj	tj
tjtjtj
tjtjtjf
kr�||j|�dS|tjfkr�|j|�S||j|�dSdS)z� Generation from a statement node. This method exists as a wrapper
            for individual visit_* methods to handle different treatment of
            some statements in this context.
        rXz;
rSN)r!rrr�Declr3ZCastZUnaryOpZBinaryOpZ	TernaryOp�FuncCall�ArrayRef�	StructRefr|r{ZTypedefr9rZCompound)rrrg�typ�indentrrrrY(s

zCGenerator._generate_stmtcCsHd}|jrdj|j�d}|jr4|dj|j�d7}||j|j�7}|S)z& Generation from a Decl node.
        rr
)ZfuncspecrrDrEr!)rrr>rrrr;DszCGenerator._generate_declcCs�t|�}|tjk�rNd}|jr2|dj|j�d7}||j|j�7}|jrN|jnd}x�t|�D]�\}}t|tj	�r�|dkr�t||dtj
�r�d|d}|d|j|j�d7}q\t|tj��r|dkr�t||dtj
�r�d|d}|d|j|j
�d7}q\t|tj
�r\|j�r,d	dj|j�|f}q\d
|}q\W|�rJ|d|7}|S|tjk�rf|j|j�S|tjk�r~|j|j�S|tjk�r�dj|j�dS|tj	tj
tjfk�r�|j|j||g�S|j|�SdS)z� Recursive generation from a type node. n is the type node.
            modifiers collects the PtrDecl, ArrayDecl and FuncDecl modifiers
            encountered on the way down to a TypeDecl, to allow proper
            generation from it.
        rr
rrr#r$rrz* %s %s�*N)r!rZTypeDeclZqualsrrZdeclnamerOr2Z	ArrayDeclZPtrDeclZdimZFuncDeclr%rr;ZTypenamerEZIdentifierTyper5)rrZ	modifiersr�r>ZnstrrPZmodifierrrrrEMs@zCGenerator._generate_typecCs&|j|�}||�rd|dS|SdS)z� Visits 'n' and returns its string representation, parenthesized
            if the condition function applied to the node returns True.
        r#r$N)r:)rrZ	conditionr>rrrr-{s
zCGenerator._parenthesize_ifcs�j|�fdd��S)z. Common use case for _parenthesize_if
        cs�j|�S)N)r*)r+)rrrr,�sz8CGenerator._parenthesize_unless_simple.<locals>.<lambda>)r-)rrr)rrr�sz&CGenerator._parenthesize_unless_simplecCst|tjtjtjtjtjf�S)z~ Returns True for nodes that are "simple" - i.e. nodes that always
            have higher precedence than operators.
        )r2rr|r{r�r�r�)rrrrrr*�szCGenerator._is_simple_nodeN)F)F)8r
�
__module__�__qualname__�__doc__r	rrrrrr r"r&r)r1r4r6r:r?rCrFrGrKrLrQrUrWr[r]r^r`rarbrfrhrjrkrlrmrorprqrrrsrvrwryr}r~rurYr;rEr-rr*rrrrrsj



		


	.
rN)rr�objectrrrrr�<module>	s

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 2.48 KB 0644
__init__.cpython-36.pyc File 2.48 KB 0644
_ast_gen.cpython-36.opt-1.pyc File 8.46 KB 0644
_ast_gen.cpython-36.pyc File 8.46 KB 0644
_build_tables.cpython-36.opt-1.pyc File 467 B 0644
_build_tables.cpython-36.pyc File 467 B 0644
ast_transforms.cpython-36.opt-1.pyc File 2.39 KB 0644
ast_transforms.cpython-36.pyc File 2.43 KB 0644
c_ast.cpython-36.opt-1.pyc File 29.03 KB 0644
c_ast.cpython-36.pyc File 29.03 KB 0644
c_generator.cpython-36.opt-1.pyc File 14.54 KB 0644
c_generator.cpython-36.pyc File 14.54 KB 0644
c_lexer.cpython-36.opt-1.pyc File 11.95 KB 0644
c_lexer.cpython-36.pyc File 11.95 KB 0644
c_parser.cpython-36.opt-1.pyc File 54.32 KB 0644
c_parser.cpython-36.pyc File 54.46 KB 0644
lextab.cpython-36.opt-1.pyc File 5.58 KB 0644
lextab.cpython-36.pyc File 5.58 KB 0644
plyparser.cpython-36.opt-1.pyc File 2 KB 0644
plyparser.cpython-36.pyc File 2 KB 0644
yacctab.cpython-36.opt-1.pyc File 103.49 KB 0644
yacctab.cpython-36.pyc File 103.49 KB 0644