gflE.ddlmZGddeZdS))c_astceZdZdZd_dZdZdZdZdZdZ d Z d Z d Z d Z d Ziddddddddddddddddddddddd d!d"d!d#d$d%d$d&d'd(d'd)d'iZd*Zd+Zd,Zd-Zd_d.Zd/Zd0Zd1Zd2Zd3Zd4Zd5Zd6Zd7Zd8Zd9Zd:Z d;Z!d<Z"d=Z#d>Z$d?Z%d@Z&dAZ'dBZ(dCZ)dDZ*dEZ+dFZ,dGZ-dHZ.dIZ/dJZ0dKZ1dLZ2dMZ3dNZ4dOZ5dPZ6dQZ7dRZ8dSZ9dTZ:dUZ;dVZgdYfdZZ?d[Z@d\ZAd]ZBd^S)` 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. Fc"d|_||_dS)z Constructs C-code generator reduce_parentheses: if True, eliminates needless parentheses on binary operators N) indent_levelreduce_parentheses)selfr s u/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pycparser/c_generator.py__init__zCGenerator.__init__s"4cd|jzSN )r)r s r _make_indentzCGenerator._make_indentsT&&&r c^d|jjz}t|||j|S)Nvisit_) __class____name__getattr generic_visit)r nodemethods r visitzCGenerator.visits0DN338wtVT%788>>>r cr|dSdfd|DS)Nc3HK|]\}}|VdSNr).0c_namecr s r z+CGenerator.generic_visit..'s1JJYVQ4::a==JJJJJJr )joinchildren)r rs` r rzCGenerator.generic_visit#s< <277JJJJ$--//JJJJJ Jr c|jSr)valuer ns r visit_ConstantzCGenerator.visit_Constant)s wr c|jSrnamer(s r visit_IDzCGenerator.visit_ID,s v r c2d}|jr |d|jzz }|S)Nz#pragmar)string)r r)rets r visit_PragmazCGenerator.visit_Pragma/s& 8 " 3> !C r c|||j}|dz||jzdzS)N[])_parenthesize_unless_simpler-r subscript)r r)arrrefs r visit_ArrayRefzCGenerator.visit_ArrayRef5s911!&99|djj555;;r c||j}||jz||jzSr)r6r-typerfield)r r)srefs r visit_StructRefzCGenerator.visit_StructRef9s6//77af}tzz!'2222r c|||j}|dz||jzdzS)N())r6r-rargs)r r)frefs r visit_FuncCallzCGenerator.visit_FuncCall=s9//77czDJJqv...44r c|jdkrd||jzS||j}|jdkrd|zS|jdkrd|zS|j|S)Nsizeofz sizeof(%s)zp++z%s++zp--z%s--)oprexprr6)r r)operands r visit_UnaryOpzCGenerator.visit_UnaryOpAs| 48   $**QV"4"44 466qv>>Gtu}}''''!"ww//r z||rz&&r|^&z==z!=>z>=>z<<+-* /%cjfd}jfd}|djd|S)Nc|pFjo?t|tjo%j|jjjk Sr_is_simple_noder isinstancerBinaryOpprecedence_maprGdr)r s r z+CGenerator.visit_BinaryOp..ks]4//22M-M*Q2O2OM)!$/43Fqt3LLNr c|pFjo?t|tjo%j|jjjk Srr_rds r rfz+CGenerator.visit_BinaryOp..ws]4//22L-L*Q2O2OL)!$/$2Ead2KKMr r)_parenthesize_ifleftrightrG)r r)lval_strrval_strs`` r visit_BinaryOpzCGenerator.visit_BinaryOp_s(( F N N N N NOO(( G M M M M MNN &XXqtttXX66r c||jd}||jd|jd|S)Nc6t|tjSr)rar Assignment)r)s r rfz-CGenerator.visit_Assignment..sjE4D&E&Er r)rhrvaluerlvaluerG)r r)rls r visit_AssignmentzCGenerator.visit_Assignment|sO((HEEGG"ZZ11111444BBr c6d|jSr)r$namesr(s r visit_IdentifierTypezCGenerator.visit_IdentifierTypesxx   r ct|tjrd||zdzSt|tjrd||zdzS||S)N{}r@rA)rarInitListrExprListr(s r _visit_exprzCGenerator._visit_exprsn a ( ( !A&, , 5> * * !A&, ,::a== r c|r|jn||}|jr |d||jzz }|jr |d||jzz }|S)Nz :  = )r-_generate_declbitsizerinitr|)r r)no_typess r visit_DeclzCGenerator.visit_Declst 9AFF4#6#6q#9#9 98a54::ai#8#888a 6 2 ))!&111 1Ar c|jd}t|jdkr4|ddfd|jddDzz }|S)Nrr, c3FK|]}|dVdS)T)rN)rr declr s r r#z,CGenerator.visit_DeclList..sG"="=(,#'//$/"E"E"="="="="="=r )rdeclslenr$r r)rs` r visit_DeclListzCGenerator.visit_DeclLists JJqwqz " " qw<.s-!G!GA$**Q--!G!G!G!G!G!Gr  )rrrbody param_declsr$)r r)rrknrdeclss` r visit_FuncDefzCGenerator.visit_FuncDefszz!&!!zz!&!! = -zz!G!G!G!G!G!G!GGGH$;)E1D84? ?$;%, ,r c&d}|jD]}t|tjr|||z }5t|tjr|||dzz }k|||dzz }|S)Nrrr)extrarFuncDefrPragma)r r)rrs r visit_FileASTzCGenerator.visit_FileASTs 5 - -C#u}-- -TZZ__$C.. -TZZ__t++TZZ__u,,r c dz}xjdz c_|jr)|dfd|jDz }xjdzc_|dzz }|S)N{ rLrc3BK|]}|VdSr_generate_stmt)r stmtr s r r#z,CGenerator.visit_Compound..s1MMt,,T22MMMMMMr z} )rr block_itemsr$rs` r visit_CompoundzCGenerator.visit_Compounds     % ' Q = N MMMMq}MMMMM MA Q T   5 ((r c~d||jzdz||jzdzS)Nr@z){ry)rr;rr(s r visit_CompoundLiteralz CGenerator.visit_CompoundLiterals8TZZ'''$.AF1C1CCcIIr cdS)N;r(s r visit_EmptyStatementzCGenerator.visit_EmptyStatementssr cPdfd|jDS)Nrc3BK|]}|VdSrr)r paramr s r r#z-CGenerator.visit_ParamList..s/AAuE**AAAAAAr )r$paramsr(s` r visit_ParamListzCGenerator.visit_ParamLists,yyAAAAAAAAAAr c^d}|jr |d||jzz }|dzS)Nreturnrr)rHrrs r visit_ReturnzCGenerator.visit_Returns4  601djj000013wr cdS)Nzbreak;rr(s r visit_BreakzCGenerator.visit_Breaksxr cdS)Nz continue;rr(s r visit_ContinuezCGenerator.visit_Continues{r cd||jzdz}|d||jzdzz }|d||jzdzz }|S)Nr@z) ? z) : rA)r|condiftrueiffalsers r visit_TernaryOpzCGenerator.visit_TernaryOpsn 4##AF++ +f 4 S4##AH-- - 66 S4##AI.. . 44r cd}|jr|||jz }|dz }|||jdz }|jr9||dzz }|||jdz }|S)Nzif () T add_indentzelse )rrrrrrrs r visit_IfzCGenerator.visit_Ifs  6*1 16***1 U  T d ; ;; 9 A ""$$x/ /A $$QY4$@@ @Ar cJd}|jr|||jz }|dz }|jr |d||jzz }|dz }|jr |d||jzz }|dz }|||jdz }|S)Nzfor (rrrTr)rrrnextrrrs r visit_ForzCGenerator.visit_For s  6*1 16***1 S 601djj00001 S 601djj00001 U  T D 9 99r cd}|jr|||jz }|dz }|||jdz }|S)Nwhile (rTr)rrrrrs r visit_WhilezCGenerator.visit_WhilesS  6*1 16***1 U  T D 9 99r cd}|||jdz }||dzz }|jr|||jz }|dz }|S)Nzdo Trrz);)rrrrrrs r visit_DoWhilezCGenerator.visit_DoWhilesn  T D 9 99 T   9 ,, 6*1 16***1 T r cd}|||jz }|jr"|dz }|||jz }|dz }|S)Nz_Static_assert(,rA)rrmessagers r visit_StaticAssertzCGenerator.visit_StaticAssert$sX  TZZ   9 ' HA AI&& &A Sr cd||jzdz}|||jdz }|S)Nzswitch (rTr)rrrrrs r visit_SwitchzCGenerator.visit_Switch-sC AF++ +e 3 T D 9 99r cd||jzdz}|jD]}|||dz }|S)Nzcase : Tr)rrHstmtsrr r)rrs r visit_CasezCGenerator.visit_Case2sT djj(( (5 0G < s#v~ 3 3AF ; ;;;r cd|jzdzS)Nzgoto rr,r(s r visit_GotozCGenerator.visit_GotoAs#%%r cdS)Nz...rr(s r visit_EllipsisParamzCGenerator.visit_EllipsisParamDsur c.||dS)Nstructrr(s r visit_StructzCGenerator.visit_StructGs//8<<>>>h.ddAH4HG 4M 3J!&,B '   IA ""$$ $A    "   JA w'' 'A    "   ""$$s* *Ar cFdfd|DS)Nrc3BK|]}|VdSrrrs r r#z9CGenerator._generate_struct_union_body..s1EETt**400EEEEEEr r$r rs` r rz&CGenerator._generate_struct_union_body~s*wwEEEEWEEEEEEr c\dfd|DdddzS)Nrc3BK|]}|VdSrr)r r'r s r r#z1CGenerator._generate_enum_body..s/>>Utzz%((>>>>>>r rrrs` r rzCGenerator._generate_enum_bodys8ww>>>>g>>>>>ssCdJJr ct|}|r|xjdz c_|}|r|xjdzc_|tjtjtjtjtjtj tj tj tj tj tjtjtjf vr|||zdzS|tjfvr||S|tjfvr|||zS|||zdzS)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. rLrr)r;rrrDeclrpCastUnaryOprb TernaryOpFuncCallArrayRef StructRefConstantrTypedefr{rCompoundIf)r r)rtyprs r rzCGenerator._generate_stmts 1gg -t((A-((""$$ -t((A-((  E,ej%-5=    DJJqMM)E1 1 U^% % % ::a== UXK  DJJqMM) )DJJqMM)D0 0r c4d}|jrd|jdz}|jr |d|jdzz }|jr&|||jddzz }|||jz }|S)z& Generation from a Decl node. rrr)funcspecr$ralignrrr;rs r rzCGenerator._generate_decls  :5388AJ//#5q 94a388AI..44a 75AAGAJ//#55A T  ( ((r Tct|}|tjkrd}|jr |d|jdzz }|||jz }|jr |r|jnd}t|D]\\}}t|tj r~|dkr+t||dz tj rd|zdz}|dz }|j r |d|j dzz }|||j dzz }t|tj rV|dkr+t||dz tj rd|zdz}|d||jzdzz }t|tj r4|jr(d d|j|rd|znd}Wd |z}^|r|d|zz }|S|tjkr||jS|tjkr||j| S|tjkrd|jdzS|tj tj tj fvr!||j||gz| S||S) 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. rrrrr@rAr4r5z* rYr)r;rTypeDeclqualsr$rdeclname enumeratera ArrayDeclPtrDecl dim_qualsdimFuncDeclrBr!rTypenamerIdentifierTyperu) r r) modifiersrr,rnstrimodifiers r rzCGenerator._generate_types 1gg %. Aw 4SXXag..44 AF## #A!"E E1::2D )33 * * 8h88*Q"9QU#3U]CC#&:#3DCKD)C); < .sd6J6J16M6M2Mr )rhr(s` r r6z&CGenerator._parenthesize_unless_simples%$$Q(M(M(M(MNNNr ct|tjtjtjtjtjfS)z~ Returns True for nodes that are "simple" - i.e. nodes that always have higher precedence than operators. )rarr(rr&r'r%r(s r r`zCGenerator._is_simple_nodes5!eneh#ou~?@@ @r N)F)Cr __module__ __qualname____doc__r rrrr*r.r2r9r>rDrJrcrmrsrvr|rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r rrrrrrrrrhr6r`rr r rr s 5 5 5 5'''???KKK  <<<333555 0 0 0  a  a  Q  Q  Q  a q  Q a a "&q  a q  Q Q  Q Q Q  N777:CCC !!!!!! BBB+++ +++ @@@>>>   ---   JJJBBB        <<<&&&===+++<<<&&&;;;;;;;;;0FFFKKK1111<+-d3!3!3!3!jOOO @@@@@r rN)rrobjectrrr r rIsaj@j@j@j@j@j@j@j@j@j@r