grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026B cGDF+d@Mã @sôdZddlZddlZddlZddlZddlTddlmZddddd d d d d ddg eZ[ejej ej e e e fZedZdd„ZdPdddœdd„ZdQddœdd„Zdddddddddd d!œ Zd"d#„Zd$d%„Zd&d„Zd'd(„Zddœd)d „Ze d*d+¡Zd,ej_d-ej_d.ej_d/ej_d0ej_d1ej _d2ej!_d3ej"_d4Z#d5Z$Gd6d„deƒZ%dd7œd8d „Z&d9d:„Z'd;d<„Z(dRd=d>„Z)dSddœd@d„Z*dddœdAdB„Z+dTdddCœdDdE„Z,dFdG„Z-e*Z.dHdI„Z/dJd „Z0dKd „Z1GdLd„dƒZ2dMdN„Z3e4dOk�rðe3ƒdS)Uz0Disassembler of Python byte code into mnemonics.éN)Ú*)Ú__all__Ú code_infoÚdisÚ disassembleÚdistbÚdiscoÚfindlinestartsÚ findlabelsÚ show_codeÚget_instructionsÚ InstructionÚBytecodeÚ FORMAT_VALUEcCs6yt||dƒ}Wn tk r0t||dƒ}YnX|S)zßAttempts to compile the given source, first as an expression and then as a statement if the first approach fails. Utility function to accept strings in functions that otherwise expect code objects ÚevalÚexec)ÚcompileÚ SyntaxError)ÚsourceÚnameÚc©rú(/opt/alt/python37/lib64/python3.7/dis.pyÚ _try_compiles r)ÚfileÚdepthc Csn|dkrt|d�dSt|dƒr&|j}t|dƒr8|j}n4t|dƒrJ|j}n"t|dƒr\|j}nt|dƒrl|j}t|dƒ�rt|j  ¡ƒ}xâ|D]p\}}t |t ƒrŒt d ||d�yt |||d �Wn0tk rð}zt d ||d�Wdd}~XYnXt |d�qŒWnht|d ƒ�rt|||d �nLt |ttfƒ�r            )rcCs\|dkrDy tj}Wntk r0tdƒd‚YnXx|jrB|j}q4Wt|jj|j|d�dS)z2Disassemble a traceback (default: last traceback).Nz no last traceback to disassemble)r) ÚsysÚlast_tracebackÚAttributeErrorÚ RuntimeErrorÚtb_nextrÚtb_frameÚf_codeÚtb_lasti)ÚtbrrrrrOs  Z OPTIMIZEDZ NEWLOCALSZVARARGSZ VARKEYWORDSZNESTEDZ GENERATORZNOFREEZ COROUTINEZITERABLE_COROUTINEZASYNC_GENERATOR) éééééé é@é€éicCsbg}xRtdƒD]8}d|>}||@r| t |t|ƒ¡¡||N}|sPqW| t|ƒ¡d |¡S)z+Return pretty representation of code flags.rBr=z, )ÚrangeÚappendÚCOMPILER_FLAG_NAMESÚgetÚhexÚjoin)ÚflagsÚnamesÚiÚflagrrrÚ pretty_flagsisrPcCsŽt|dƒr|j}t|dƒr"|j}n4t|dƒr4|j}n"t|dƒrF|j}nt|dƒrV|j}t|tƒrjt|dƒ}t|dƒrx|St dt |ƒj ƒ‚d S) zDHelper to handle methods, compiled or raw code objects, and strings.rrrrr z r"z(don't know how to disassemble %s objectsN) r#rrrrr r&r.rr)r0r1)r2rrrÚ_get_code_objectws         rQcCs tt|ƒƒS)z1Formatted details of methods, functions, or code.)Ú_format_code_inforQ)r2rrrrŽscCs†g}| d|j¡| d|j¡| d|j¡| d|j¡| d|j¡| d|j¡| dt|jƒ¡|j rª| d¡x t |j ƒD]}| d |¡q”W|j rÜ| d ¡x t |j ƒD]}| d |¡qÆW|j �r| d ¡x t |j ƒD]}| d |¡qúW|j �rF| d ¡x"t |j ƒD]}| d |¡�q.W|j�r|| d¡x"t |jƒD]}| d |¡�qdWd |¡S)NzName: %szFilename: %szArgument count: %szKw-only arguments: %szNumber of locals: %szStack size: %szFlags: %sz Constants:z%4d: %rzNames:z%4d: %szVariable names:zFree variables:zCell variables:Ú )rGÚco_nameÚ co_filenameÚ co_argcountÚco_kwonlyargcountÚ co_nlocalsÚ co_stacksizerPÚco_flagsÚ co_constsÚ enumerateÚco_namesÚ co_varnamesÚ co_freevarsÚ co_cellvarsrK)ÚcoÚlinesZi_cZi_nrrrrR’s:     rRcCstt|ƒ|d�dS)z}Print details of methods, functions, or code to *file*. If *file* is not provided, the output is printed on stdout. )rN)r(r)rarrrrr ±sÚ _InstructionzBopname opcode arg argval argrepr offset starts_line is_jump_targetz!Human readable name for operationzNumeric code for operationz6Numeric argument to operation (if any), otherwise Nonez4Resolved arg value (if known), otherwise same as argz0Human readable description of operation argumentz1Start index of operation within bytecode sequencez4Line started by this opcode (if any), otherwise Nonez1True if other code jumps to here, otherwise Falseééc@seZdZdZddd„ZdS) r aKDetails for a bytecode operation Defined fields: opname - human readable name for operation opcode - numeric code for operation arg - numeric argument to operation (if any), otherwise None argval - resolved arg value (if known), otherwise same as arg argrepr - human readable description of operation argument offset - start index of operation within bytecode sequence starts_line - line started by this opcode (if any), otherwise None is_jump_target - True if other code jumps to here, otherwise False éFr?cCsàg}|r:|jdk r,d|}| ||j¡n| d|¡|rJ| d¡n | d¡|jrf| d¡n | d¡| t|jƒ |¡¡| |j t¡¡|j dk rÒ| t|j ƒ t ¡¡|j rÒ| d|j d ¡d  |¡  ¡S) a%Format instruction details for inclusion in disassembly output *lineno_width* sets the width of the line number field (0 omits it) *mark_as_current* inserts a '-->' marker arrow as part of the line *offset_width* sets the width of the instruction offset field Nz%%%ddú z-->z z>>z ú(ú))Ú starts_linerGÚis_jump_targetÚreprÚoffsetÚrjustÚopnameÚljustÚ _OPNAME_WIDTHÚargÚ _OPARG_WIDTHÚargreprrKÚrstrip)ÚselfÚ lineno_widthZmark_as_currentÚ offset_widthZfieldsZ lineno_fmtrrrÚ _disassembleÕs&      zInstruction._disassembleN)rfFr?)r1Ú __module__Ú __qualname__Ú__doc__ryrrrrr Çs )Ú first_linecCsTt|ƒ}|j|j}tt|ƒƒ}|dk r4||j}nd}t|j|j|j |j |||ƒS)a«Iterator for the opcodes in methods, functions or code Generates a series of Instruction named tuples giving the details of each operations in the supplied code. If *first_line* is not None, it indicates the line number that should be reported for the first source line in the disassembled code. Otherwise, the source line information (if any) is taken directly from the disassembled code object. Nr) rQr`r_Údictr Úco_firstlinenoÚ_get_instructions_bytesr"r^r]r[)r2r}raÚ cell_namesÚ linestartsÚ line_offsetrrrr ûs    cCs |}|dk r||}|t|ƒfS)zÕHelper to get optional details about const references Returns the dereferenced constant and its repr if the constant list is defined. Otherwise returns the constant index and its repr(). N)rl)Z const_indexZ const_listÚargvalrrrÚ_get_const_infosr…cCs*|}|dk r||}|}nt|ƒ}||fS)zÓHelper to get optional details about named references Returns the dereferenced name as both value and repr if the name list is defined. Otherwise returns the name index and its repr(). N)rl)Z name_indexZ name_listr„rtrrrÚ_get_name_infos r†c csxt|ƒ}d}�xdt|ƒD�]V\} } } |dk rH| | d¡}|dk rH||7}| |k} d} d}| dk �rT| } | tkr~t| |ƒ\} }nÖ| tkr–t| |ƒ\} }n¾| tkr¸| d| } dt| ƒ}nœ| t krÐt| |ƒ\} }n„| t kræt | } | }nn| t krþt| |ƒ\} }nV| t k�rTdtttf| d@t| d@ƒf} d| d@}| d�rT|�rL|d 7}|d 7}tt| | | | || || ƒVqWdS) a&Iterate over the instructions in a bytecode string. Generates a sequence of Instruction namedtuples giving the details of each opcode. Additional information about the code's runtime environment (e.g. variable names, constants) can be specified using optional arguments. NÚr>zto rfr?)r‡r.rlÚasciir=z, z with format)r Ú_unpack_opargsrIZhasconstr…Zhasnamer†ÚhasjrelrlZhaslocalZ hascompareZcmp_opZhasfreerr.rˆÚboolr ro)ÚcodeÚvarnamesrMÚ constantsÚcellsr‚rƒÚlabelsrjrmÚoprrrkr„rtrrrr€-sH         r€éÿÿÿÿc Cs<|j|j}tt|ƒƒ}t|j||j|j|j|||d�dS)zDisassemble a code object.)rN) r`r_r~r r-r"r^r]r[)raÚlastirr�r‚rrrr`s  cCstt||d�|dks|dkrp|dk r,|d}xB|jD]8}t|dƒr4t|d�td|f|d�t|||d�q4WdS)N)rrr=r"zDisassembly of %r:)rr)rr[r#r(r*)rarrr2rrrr*gs    r*)rrƒc CsÌ|dk } | r8t| ¡ƒ|} | dkr2tt| ƒƒ} qi'r?)rƒ)r) ÚmaxÚvaluesÚlenr.r€rjrmr(ry)rŒr“r�rMrŽr�r‚rrƒZ show_linenoZ maxlinenorwZ maxoffsetrxZinstrZnew_source_lineZis_current_instrrrrr-rs,       r-cKstt|dƒf|ŽdS)zN)r*r)rÚkwargsrrrr/�sr/ccshd}x^tdt|ƒdƒD]J}||}|tkrP||d|B}|tkrJ|d>nd}nd}|||fVqWdS)Nrr>r=r@)rFr–Z HAVE_ARGUMENTZ EXTENDED_ARG)rŒZ extended_argrNr‘rrrrrr‰–sr‰cCs`g}xVt|ƒD]J\}}}|dk r|tkr6|d|}n|tkr|}nq||kr| |¡qW|S)z`Detect all offsets in a byte code which are jump targets. Return the list of offsets. Nr>)r‰rŠZhasjabsrG)rŒr�rmr‘rrZlabelrrrr ¡sccs–|jddd…}|jddd…}d}|j}d}xPt||ƒD]B\}}|rd||kr\||fV|}||7}|dkrt|d8}||7}q:W||kr’||fVdS)z”Find the offsets in a byte code which are start of lines in the source. Generate pairs (offset, lineno) as described in Python/compile.c. rNr>r=rDrE)Ú co_lnotabrÚzip)rŒZbyte_incrementsZline_incrementsZ lastlinenoÚlinenoZaddrZ byte_incrZ line_incrrrrr ´s   c@sLeZdZdZdddœdd„Zdd„Zdd „Zed d „ƒZd d „Z dd„Z dS)raThe bytecode operations of a piece of code Instantiate this with a function, method, other compiled object, string of code, or a code object (as returned by compile()). Iterating over this yields the bytecode operations as Instruction instances. N)r}Úcurrent_offsetcCsdt|ƒ|_}|dkr&|j|_d|_n||_||j|_|j|j|_tt |ƒƒ|_ ||_ ||_ dS)Nr) rQÚcodeobjrr}Ú _line_offsetr`r_Ú _cell_namesr~r Ú _linestartsÚ_original_objectr›)rvr2r}r›rarrrÚ__init__Õs zBytecode.__init__c Cs*|j}t|j|j|j|j|j|j|jd�S)N)rƒ) rœr€r"r^r]r[ržrŸr�)rvrarrrÚ__iter__âs zBytecode.__iter__cCsd |jj|j¡S)Nz{}({!r}))ÚformatÚ __class__r1r )rvrrrÚ__repr__és zBytecode.__repr__cCs$x|jr|j}qW||jj|jd�S)z/ Construct a Bytecode from the given traceback )r›)r8r9r:r;)Úclsr<rrrÚfrom_tracebackís zBytecode.from_tracebackcCs t|jƒS)z3Return formatted information about the code object.)rRrœ)rvrrrÚinfoôsz Bytecode.infoc Cs`|j}|jdk r|j}nd}t ¡�2}t|j|j|j|j|j |j |j ||d� |  ¡SQRXdS)z3Return a formatted view of the bytecode operations.Nr’)r�rMrŽr�r‚rƒrr“) rœr›ÚioÚStringIOr-r"r^r]r[ržrŸr�Úgetvalue)rvrarmÚoutputrrrrøs   z Bytecode.dis) r1rzr{r|r¡r¢r¥Ú classmethodr§r¨rrrrrrÍs  c Csdddl}| ¡}|jd| ¡ddd�| ¡}|j�}| ¡}WdQRXt||jjdƒ}t |ƒdS)z*Simple test program to disassemble a file.rNÚinfileú?ú-)r0ÚnargsÚdefaultr) ÚargparseÚArgumentParserÚ add_argumentZFileTypeÚ parse_argsr®Úreadrrr)r³ÚparserÚargsr®rrŒrrrÚ_test srºÚ__main__)N)N)NNNNNr)r’)r’NNNNN)5r|r4ÚtypesÚ collectionsr©ZopcoderZ _opcodes_allÚ MethodTypeÚ FunctionTypeÚCodeTyper­Ú staticmethodr0r'ZopmaprrrrrHrPrQrrRr Ú namedtuplercrorrr„rtrmrjrkrqrsr r r…r†r€rr*r-r/rr‰r r rrºr1rrrrÚs~     -4  2  =