
    Ijd                       d Z ddlmZ ddlZddlZddlZddlZddlZddlm	Z	 ddl
mZ ej                  j                  d e e	e      j!                         j"                               ddlmZmZmZ ddlmZmZmZ  e	e      j!                         j4                  d   Zed	z  Zd
ZdZg dZh dZ g dZ!g dZ"ddZ#ddZ$ddZ%d dZ&d!dZ'd"d#dZ(d$dZ)d%dZ*	 	 	 d&	 	 	 	 	 	 	 	 	 d'dZ+d(dZ,d(dZ-edfd)dZ.d*dZ/e0dk(  r e/        yy)+zLMap route-relevant save-selector low bytes that resolve to data descriptors.    )annotationsN)Path)Any)offset_to_varead_sectionsva_to_offset)HANDLER_TABLE_VAhandler_for_opcodesection_name_for_va   outmap1_01amap2_02d))route-dispatch-stopi(T )wrapper-child-pointeri*T )direct-leaf-entry-0i)T )zdirect-leaf-entry-1i)T )predecessor-root-entry-stopiG )predecessor-fill-fragment-stopiDH >   .text.rdata.data)zruntime-leaf-selectionz$reader-control-path-after-descriptorz%predecessor-root-to-fill-control-pathz"predecessor-fill-descriptor-bridgezstrict-source-hotspot)zNruntime selector/index choosing wrapper 0x00542a04 or frontier leaf 0x00542ae8zKcontrol path reaching reader 0x00542b0c after the route descriptor boundaryzRdecoded or observed predecessor root path from 0x004783e0 to 0x004844d0/0x004844d8zPexecution bridge across predecessor fill-fragment descriptor boundary 0x004844dcz,strict map1_01a source coordinate or hotspotc                    | d| dS d S )N0x08x values    O/home/exedev/hwanse/tools/summarize_save_selector_data_descriptor_opcode_map.pyhex32r   0   s    $0Rc{:d:    c                *    | y | dk  rd| dS d| dS )N   r   02xxr   r   s    r   
hex_opcoder%   4   s,    }$}Rc{@BuQi.@r    c                v    t        ||      }||dz   t        |       kD  ry t        j                  d| |      d   S )N   <Ir   )r   lenstructunpack_from)exesectionsvaoffsets       r   dword_atr0   :   s?    (B'F~!c#h.dC033r    c                N    | D ]   }|d   }||d   z   }||cxk  r	|k  s|c S  " y )Nrawraw_sizer   )r-   r/   sectionstartends        r   section_for_offsetr7   A   sE     gj))F S N !
 r    c                   t        j                  d|      }g }d}	 | j                  ||      }|dk  r	 |S |dz   }t        ||      }||d   t        vr:t        ||      }|I|t        z
  }	|	dk\  r|	dz  dk(  r|	dz  nd }
|j                  |d   d|dt        |      t        |      |
t        |
      |
d uxr d|
cxk  xr dk  nc |
d uxr d|
cxk  xr d	k  nc d
       )Nr(   r   r   namer'   r   06xr"   i  )r4   fileOffsetHexrefVaHexvalueHexhandlerTableOpcodehandlerTableOpcodeHexisByteOpcodeHandlerEntryisTableAlignedRef)
r*   packfindr7   SCAN_SECTIONSr   r	   appendr   r%   )r,   r-   r   needlerefssearchhitr4   ref_vaentry_offsethandler_opcodes              r   
value_refsrM   J   s   [[u%FDF
hhvv&7( K' q$Xs3?gfo]Bh,> 00.:a.?LSTDTXYDY*_cv!#c^fe"0%/%?(6d(B(bqNGb^bGb!/t!;!\^@\W\@\	
 		 r    c                    g }t        |      D ]W  }||dz  z   }t        | ||      }|t        ||      nd }|j                  t	        |      t	        |      ||rdn|dndd       Y |S )Nr'   pointerscalar
unreadable)vaHexr=   valueSectionkind)ranger0   r   rE   r   )	r,   r-   start_vacountrowsindexr.   r   r4   s	            r   descriptor_windowrZ   h   s    Du 		!h+:?:K%h6QU2Ye#!(I%:KhQ]	
 			 Kr    c                Z   t        | ||      }||dz  nd }t        | ||xs d      }|t        |      t        |      |t        ||      nd |t	        |      |j                  d      |j                  d      |j                  d      |j                  d      |j                  d      dk(  dS )	Nr"   r   
entryVaHexhandlerVaHexhandlerSectionisCodeHandlerr   )role	siteVaHexr=   rS   lowByteOpcodelowByteOpcodeHexhandlerEntryVaHexhandlerValueHexr^   r_   isDataDescriptor)r0   r
   r   r   r%   get)r,   r-   r`   r.   r   opcodehandlers          r   site_rowrj   w   s    S(B'E".UT\DF h!<G2Y%L@E@Q+He<W[&v.$[[6";;~6!++&67 _5#KK(89WD r    c                $   t        |d      }t        | ||      }|D cg c]  }|j                  d      s| }}|D cg c]  }|j                  d      s| }}|D cg c]  }|j                  d      r|d    }}|D cg c]  }|j                  d      r|d    }	}|t        ||      t	        |      t        |D ch c]  }|d   	 c}      t	        |      |t	        |      |	|t        | ||      d
S c c}w c c}w c c}w c c}w c c}w )N   r@   rA   r?   r4   )
descriptorVaHexdescriptorSectionpointerRefCountpointerRefSectionsbyteOpcodeHandlerEntryCountsharedHandlerOpcodestableAlignedRefCounttableAlignedRefIndexesrG   descriptorWindow)intrM   rg   r   r)   sortedrZ   )
r,   r-   
target_hextargetrG   refhandler_refstable_aligned_refshandler_opcode_hexestable_aligned_ref_hexess
             r   data_descriptor_summaryr      s7   R Fc8V,D#'OC3773M+NCOLO)-N#9L1M#NN  77*+ 	#$  &77*+ 	#$  &06Bt9$%Ec)n%EF'*<'8 4 #$6 7"9-c8VD  PN
 &Fs'   C9C9C>C> DDDc           
        t        |       }t        D cg c]  \  }}t        | |||       }}}t        |D ch c],  }|j	                  d      dk(  r|j	                  d      r|d   . c}      }	|	D 
cg c]  }
t        | ||
       }}
|D ci c]  }|d   |
 }}|j	                  d      xs i }|j	                  d      xs i }|j	                  d      xs i }|j	                  d      xs i }|j	                  d	      xs i }|j	                  d
      dk(  xr@ |j	                  d
      dk(  xr* |j	                  d      dk(  xr |j	                  d      dk(  }|j	                  d      dk(  xr# |j	                  d      |j	                  d      k7  }t        d |D        i       }t        d |D        i       }t        d |D        i       }|j	                  d
      dk(  xr* |j	                  d      dk(  xr |j	                  d      dk(  }|j	                  d
      dk(  xr* |j	                  d      dk(  xr |j	                  d      dk(  }d}dg dddg dddg dddg ddg}i dt        dt        d t        t              d!|d"|d#|d$|d%|d&|d'|j	                  d(      xs g d)|j	                  d*      xs g d+|j	                  d,      xs g d-|j	                  d(      xs g d.|j	                  d*      xs g d/|j	                  d,      xs g d0|j	                  d(      xs g d1|j	                  d*      xs g i d2|j	                  d,      xs g d3|xs i j	                  d4      d5|xs i j	                  d6      d7|xs i j	                  d7      d8|xs i j	                  d8      d9|xs i j	                  d9      d:|xs i j	                  d:      d;|xs i j	                  d;      d<|xs i j	                  d<      d=d>d?d>d@t        dAt        dB|dCt        |      d4dDdEg dFdG|iS c c}}w c c}w c c}
w c c}w )HNr^   r   re   r`   r   r   r   r   r   rc   0xe8
0x00440c28
0x00440c5cc              3  2   K   | ]  }|d    dk(  s|  yw)rm   r   Nr   .0rows     r   	<genexpr>z build_summary.<locals>.<genexpr>        h#EVAW[gAg#h   c              3  2   K   | ]  }|d    dk(  s|  yw)rm   
0x00440a9cNr   r   s     r   r   z build_summary.<locals>.<genexpr>   r   r   c              3  2   K   | ]  }|d    dk(  s|  yw)rm   r   Nr   r   s     r   r   z build_summary.<locals>.<genexpr>   r   r   0xd0r   0xc0ai  The route dispatch stop at 0x005428f4 and the wrapper child pointer at 0x00542a08 both resolve low byte 0xe8 through the save-selector table to data descriptor 0x00440c28. That descriptor is shared by byte-opcode entries 0xa7, 0xaf, 0xe0, and 0xe8; its table-aligned refs also include 0x100 and 0x109, and all refs are data-only. The direct current-root leaf entry 0x005429f4 resolves through a different data descriptor, 0x00440c5c. The predecessor root-entry traversal stop at 0x004783e0 resolves low byte 0xd0 to data descriptor 0x00440a9c, while the predecessor fill-fragment stop at 0x004844dc resolves low byte 0xc0 to descriptor 0x00440c5c. Each row is a data-descriptor boundary, not executable control-flow proof that the route dispatch reaches wrapper 0x00542a04, frontier leaf 0x00542ae8, reader 0x00542b0c, or the predecessor fill sites from the 1:0 root entry.Hwanse2.exe)zhandler table 0x00440720zroute-dispatch-stop 0x005428f4z wrapper-child-pointer 0x00542a08z&predecessor-root-entry-stop 0x004783e0z)predecessor-fill-fragment-stop 0x004844dc)pathfieldsz,out/save_selector_dispatch_stop_context.json)promotionStatusrouteStopVaHexwrapperChildPointerVaHexfrontierReaderHexz)out/save_selector_leaf_table_context.json)runtimeSelectionProvenwrapperLeafHexfrontierLeafHexr   z-out/save_selector_opcode24_payload_table.json)payloadDirectlyTargetsLeafTablepayloadGraphEdgeCountpayloadGraphAllEdgesLocal!payloadGraphReachesFrontierTargetsourcery   handlerTableVaHexsitesdataDescriptors routeAndWrapperShareE8Descriptor directLeafUsesDistinctDescriptor#predecessorRootStopIsDataDescriptor#predecessorFillStopIsDataDescriptor d0DescriptorSharedHandlerOpcodesrr   "d0DescriptorTableAlignedRefIndexesrt   d0DescriptorPointerRefSectionsrp    c0DescriptorSharedHandlerOpcodes"c0DescriptorTableAlignedRefIndexesc0DescriptorPointerRefSections e8DescriptorSharedHandlerOpcodes"e8DescriptorTableAlignedRefIndexese8DescriptorPointerRefSectionsdispatchStopContextStatusr   leafTableRuntimeSelectionProvenr   r   r   payloadGraphComponentCountpayloadGraphExternalEdgeCountr   r   
proofFoundFdataDescriptorOpcodeProofFoundfailedDataDescriptorGateIdsmissingEvidenceevidenceRefsevidenceRefCountblockedremainingProofs)zIprove runtime selection of wrapper 0x00542a04 or frontier leaf 0x00542ae8zNprove the control path reaches reader 0x00542b0c after the descriptor boundaryz[decode or observe the non-linear predecessor root path from 0x004783e0 to the fill fragmentzibridge the predecessor fill-fragment descriptor boundary at 0x004844dc without guessing through data rowsz3find a strict map1_01a source coordinate or hotspot
conclusion)r   RELEVANT_SITESrj   rw   rg   r   nextROUTE_SOURCEROUTE_TARGETr   r	   FAILED_DATA_DESCRIPTOR_GATE_IDSMISSING_EVIDENCEr)   )r,   dispatch_stop_contextleaf_table_contextopcode24_payload_tabler-   r`   r.   r   r   data_targetsry   descriptor_summariesby_role
route_stopwrapper_childdirect_leafpredecessor_root_stoppredecessor_fill_stop%route_and_wrapper_share_e8_descriptor$direct_leaf_uses_distinct_descriptore8_descriptord0_descriptorc0_descriptor#predecessor_root_stop_is_descriptor#predecessor_fill_stop_is_descriptorr   evidence_refss                              r   build_summaryr      s    S!H?MN84Xc8T2.NEN77#$/CGG<M4N 	 L
 Zffv3C6Jff+01Cs6{C1G1239rJKK 78>BM++34:K#KK(EFL"#KK(HIOR)*f4 	A01V;	ANN,-=	A /0L@	 * 	)*l: 	TOO-.*..AR2SS ) h)=hjlmMh)=hjlmMh)=hjlmM!!"45? 	C!%%&78LH	C!%%&677B ( 	!!"45? 	C!%%&78LH	C!%%&677B (	A  "		
 C	
 @	
 D	
;&MN*,*,* 	U#34* 		*
 	/* 	+,Q* 	+,P* 	./R* 	./R* 	+M,=,=>T,U,[Y[* 	-m.?.?@X.Y._]_* 	)-*;*;<P*Q*WUW* 	+M,=,=>T,U,[Y[* 	-m.?.?@X.Y._]_* 	)-*;*;<P*Q*WUW*  	+M,=,=>T,U,[Y[!*" 	-m.?.?@X.Y._]_#*$ 	)-*;*;<P*Q*WUW%*& 	$&;&Ar%F%FGX%Y'*( 	*,>,D"+I+IJb+c)** 	*,B,Hb+M+MNo+p+*, 	 "8">B!C!CD[!\-*. 	%'='C&H&HIe&f/*0 	(*@*FB)K)KLk)l1*2 	$&<&B%G%GHc%d3*4 	,.D.J-O-OPs-t5*6 	e7*8 	)%9*: 	&'F;*< 	+=*> 	?*@ 	C.A*B 	9C*D 	 
E*R 	jS* *m O
 g1s   Q1Q
5QQc                Z   ddd| d    d| d    d| d    d	d
| d    ddj                  | d         xs d ddj                  | d         xs d ddj                  | d         xs d d| d    d| d    ddj                  | d         xs d d| d    ddj                  | d         xs d d| d    d | d!    d"| d#    d$| d%    d&| d'    d(dj                  | d)         xs d d*t        | d+          d,| d-    d.| d/    d| d0   dd1dd2d3g}| d4   D ]`  }|j                  d5|d6    d7|d8    d9|d:    d9|d;    d9|d<    d9|d=    d>|j                  d?      xs d d@|j                  dA       dB       b |j	                  g dC       | dD   D ]+  }|j	                  dE|dF    ddG|dH    dIdj                  |dJ         xs d dKdj                  |dL         xs d dMdj                  |dN         xs d ddOdPg       |dQ   D ]<  }|j                  dR|dS    d9|d:    d>|dT    d@|j                  dU      xs d dB	       > |j	                  g dV       |dW   D ]H  }|j                  dR|dX    d>|dY    d@|j                  dZ       d@|j                  d[      xs d dB	       J |j                  d       . |j	                  d\dg       | d]   D ]  }|j                  d^|         |j	                  g d_       | d+   D ]  }|j                  d^|         |j	                  g d`       | da   D ]B  }|j                  d^|db    dcdj                  |j                  dd      xs g       xs d        D |j                  d       dej                  |      S )fNz*# Save Selector Data Descriptor Opcode Map z	- route: r   z -> ry   z- handler table: `r   `z+- route and wrapper share 0xe8 descriptor: r   z- e8 shared handler opcodes: , r   -z- e8 table-aligned refs: r   z- e8 descriptor refs: r   z(- direct leaf uses distinct descriptor: r   z,- predecessor root stop is data descriptor: r   z- d0 shared handler opcodes: r   z,- predecessor fill stop is data descriptor: r   z- c0 shared handler opcodes: r   z'- payload directly targets leaf table: r   z- payload graph components: r   z!- payload graph all edges local: r   z)- payload graph reaches frontier target: r   z- proof found: r   z - failed data-descriptor gates: r   z- missing evidence count: r   z- evidence refs: r   z- promotion status: r   r   z## Relevant SiteszT| role | site | value | low byte | handler entry | handler value | section | code? |z1| --- | --- | --- | --- | --- | --- | --- | --- |r   z| r`   z | `ra   z` | `r=   rc   rd   re   z` | r^   z | r_   z |)r   z## Data Descriptorsr   r   z### rm   z- refs: ro    in rp   z- byte-opcode handler entries: rr   z- table-aligned refs: rt   z%| va | value | kind | value section || --- | --- | --- | --- |ru   z| `rR   rT   rS   )r   zRefs:r   z.| ref | section | byte opcode? | table index |r   rG   r<   r4   r@   r?   z## Remaining Proofsr   z- )r   z## Missing Evidencer   )r   z## Evidence Refsr   r   r   z: r   
)joinr)   rE   rg   extend)summarylinesr   
descriptorrz   proofitems          r   markdownr   1  sD   4

GH%&d78+<*=>
W%89:!<
5g>`6a5bc
'		':\2](^(ebe'fg
#DIIg6Z.[$\$c`c#de
 73S+T!U!\Y\ ]^
27;]3^2_`
6w?d7e6fg
'		':\2](^(ebe'fg
6w?d7e6fg
'		':\2](^(ebe'fg
1':[2\1]^
&w/K'L&MN
+G4O,P+QR
3G<_4`3ab
',/01
*499W=Z5[+\+c`c*de
$S1B)C%D$EF
G$6789
w'89:;


^;;E> w 
VT#k"2!35Z8IsSeOfNg h'()s3D/E.Fd377ScKdKkhkJllopspwpw  yH  qI  pJ  JLM	


 
LL01/0 
:/012z"345T$))JOcDd:e:lil9mn-dii
CY8Z.[.b_b-cd$TYYz:R/S%T%[X[$\]3'	
 		 01 	CLLc'l^5Z(9c&k]#cggVdNeNlilMmmop	 	uvf% 	CLLc*o&d3y>*:#cggF`>a=bbefifmfm  oF  gG  gN  KN  fO  OQ  R	 	R)* 
LL',-*+ #r%\"#	LL01)* "r$[!"	LL-.~& Vr#f+b37783D3J)K)Rs(STUV	LL99Ur    c                |   drdg }| d   D ]  }|j                  d |d          d |d          d |d          d |d	          d |d
          d |d          d |j                  d      xs d       d |j                  d             d        g }| d   D ]v  }g }|d   D ]T  }|j                  d |d          d |d          d |d          d |j                  d      xs d       d	       V g }|d   D ]`  }|j                  d |d          d |d          d |j                  d             d |j                  d      xs d       d	       b |j                  d |d          d |d           d! d"j                  |d#         xs d       d$ d"j                  |d%         xs d       d& d"j                  |d'         xs d       d(d)j                  |       d*d)j                  |       d+       y d)j                  fd,| d-   D              }d)j                  fd.| d/   D              }	d)j                  fd0| d1   D              }
d2j                  d3d4d5d6d7d8d9d:d;d<d= | d>          d? | d@          dA | dB          dC | dD          dE	dF | dG          dH d"j                  | dI         xs d       dJ d"j                  | dK         xs d       dL | dM          dE	dN | dO          dP d"j                  | dQ         xs d       dR | dS          dT d"j                  | dU         xs d       dE	dV | dW          dX | dY          dZ | d[          d\ | d]          dE	d^ | d_          d` d"j                  | da         xs d       db t        | d/                dc | dd          dE	de | df          dgdhdidjd)j                  |       d+d2j                  |      dkdl| dmdndl|	 dmdodl|
 dmdpdqd)g      S )sNc                >    t        j                  t        |             S )N)htmlescapestrr   s    r   esczhtml_page.<locals>.escz  s    {{3u:&&r    r   z<tr><td>r`   z</td><td><code>ra   z</code></td><td><code>r=   rc   rd   re   z</code></td><td>r^   r   z	</td><td>r_   z
</td></tr>r   ru   z<tr><td><code>rR   rT   rS   rG   r<   r4   r@   r?   z<h2>rm   z</h2><p>refs: ro   r   r   rp   z; byte-opcode handler entries: rr   z; table-aligned refs: rt   zf</p><table><thead><tr><th>va</th><th>value</th><th>kind</th><th>value section</th></tr></thead><tbody>r   z{</tbody></table><table><thead><tr><th>ref</th><th>section</th><th>byte opcode?</th><th>table index</th></tr></thead><tbody>z</tbody></table>c              3  6   K   | ]  }d  |       d  ywz<li></li>Nr   )r   r   r   s     r   r   zhtml_page.<locals>.<genexpr>  s     [uDUE2[   r   c              3  6   K   | ]  }d  |       d  ywr   r   )r   r   r   s     r   r   zhtml_page.<locals>.<genexpr>  s     [d3t9+U3[r   r   c              3     K   | ]B  }d  |d          d dj                  |j                  d      xs g       xs d       d D yw)z
<li><code>r   z	</code>: r   r   r   r   N)r   rg   )r   rz   r   s     r   r   zhtml_page.<locals>.<genexpr>  sW      ! SV%&iDIIcggh>O>USU4V4]Z]0^/__de!s   AAr   r   z<!doctype html>z<html lang="en">z<head>z  <meta charset="utf-8">zF  <meta name="viewport" content="width=device-width, initial-scale=1">z9  <title>Save Selector Data Descriptor Opcode Map</title>a    <style>body{margin:24px;background:#101010;color:#eee;font:14px system-ui,sans-serif}table{border-collapse:collapse;width:100%;margin:16px 0 28px}th,td{border:1px solid #333;padding:6px 8px;vertical-align:top}th{background:#1d1d1d}code{color:#f5d76e}</style>z</head>z<body>z3  <h1>Save Selector Data Descriptor Opcode Map</h1>z  <p>route <code>r   z</code> -&gt; <code>ry   z</code>; handler table <code>r   z</code>; promotion status: r   z.</p>z.  <p>route and wrapper share 0xe8 descriptor: r   z; e8 shared handler opcodes: r   z; e8 table-aligned refs: r   z(; direct leaf uses distinct descriptor: r   z/  <p>predecessor root stop is data descriptor: r   z; d0 shared handler opcodes: r   z,; predecessor fill stop is data descriptor: r   z; c0 shared handler opcodes: r   z  <p>payload graph components: r   z!; payload graph all edges local: r   z); payload graph reaches frontier target: r   z'; payload directly targets leaf table: r   z  <p>proofFound: r   z; failedDataDescriptorGates: r   z; missingEvidenceCount: z; evidenceRefs: r   z  <p>r   z</p>z  <h2>Relevant Sites</h2>z  <table><thead><tr><th>role</th><th>site</th><th>value</th><th>low byte</th><th>handler entry</th><th>handler value</th><th>section</th><th>code?</th></tr></thead>z	  <tbody>z  <h2>Remaining Proofs</h2>z  <ul>z</ul>z  <h2>Missing Evidence</h2>z  <h2>Evidence Refs</h2>z</body>z</html>)r   r   returnr   )rE   rg   r   r)   )r   	site_rowsr   descriptor_sectionsr   window_rowsref_rowsrz   proof_itemsmissing_itemsevidence_ref_itemsr   s              @r   	html_pager   y  sJ   ' Iw 
s6{#$ %S-./ 0S_-. /S!3456 7S!4567 8S!2345 6sww/07C89 :sww/01 2		

 /0 

01 	C W./ 0 Z12 33v;'( )377>29c:; <		 f% 	COO Z12 33y>*+ ,377#=>?@ A377#:;BsCD E		 	""3z"3456 7J'89:;4DIIjYmNnDoDvsv@w?x y,,/		*E[:\0]0dad,e+f g##&tyy<T1U'V']Z]#^"_ `ggk*+ ,ggh'((8:		
+
> ''[HY@Z[[KGG[HY@Z[[M !>*!  99"PC 	O=
C 1233GGT\L]H^G_ `"7+>#?@AA\]`ahiza{]|\}  ~C	D
8WEg=h9i8j k&&)$))G<^4_*`*gdg&h%i j""%dii8\0]&^&ebe"f!g h114W=_5`1a0bbg	i :#gFk>l:m9n o&&)$))G<^4_*`*gdg&h%i j558Af9g5h4i j&&)$))G<^4_*`*gdg&h%iin	p *#g6R.S*T)U V**-g6Q.R*S)T U225g>a6b2c1d e003G<]4^0_/``e	g C 567 8&&)$))G<Y4Z*[*b_b&c%d e!!$S1B)C%D!E F GW%789:%	A GL)*+40# 	o
BGGI&''78		%&%
U#%
u%"
#$E*
U+ + +r    c                    |j                  dd       |dz  j                  t        j                  | dd      d       |:|j                  j                  dd       |j                  t        |       d       y y )	NT)parentsexist_ok-save_selector_data_descriptor_opcode_map.jsonF),:)ensure_ascii
separatorsutf-8encoding)mkdir
write_textjsondumpsparentr   )r   out_dirhtml_outs      r   write_outputsr    s{    MM$M.>>JJ

7:F K  dT:Ig.A r    c            
     R   t        j                  t              } | j                  dt        t
        dz         | j                  dt        t        dz         | j                  dt        t        dz         | j                  d	t        t        d
z         | j                  dt        t               | j                  dt        d d       | j                         }t        |j                  j                         |j                  j                         r/t        j                  |j                  j                  d            ni |j                   j                         r/t        j                  |j                   j                  d            ni |j"                  j                         r/t        j                  |j"                  j                  d            ni       }t%        ||j&                  |j(                         t+        dt-        |d          d|j&                  dz          y )N)descriptionz--exer   )typedefaultz--dispatch-stop-contextz(save_selector_dispatch_stop_context.jsonz--leaf-table-contextz%save_selector_leaf_table_context.jsonz--opcode24-payload-tablez)save_selector_opcode24_payload_table.jsonz	--out-dirz
--html-outz!Optional HTML report output path.)r  r  helpr  r  z0wrote save-selector data descriptor opcode map (r   z descriptors) -> r   )argparseArgumentParser__doc__add_argumentr   ROOTOUT
parse_argsr   r,   
read_bytesr   existsr  loads	read_textr   r   r  r  r  printr)   )parserargsr   s      r   mainr!    s   $$9F
dD=4HI
1cLvFvw
.T3IpCpq
2sMxGxy
$<
4DghDNRNhNhNoNoNq

4--777IJwyKOKbKbKiKiKk

4**44g4FGqsOSOjOjOqOqOs

4..88'8JKy{	G '4<<7		)*+,,=dllM|>|=}	r    __main__)r   
int | Noner   z
str | None)r,   bytesr-   
list[dict]r.   rv   r   r#  )r-   r%  r/   rv   r   dict | None)r,   r$  r-   r%  r   rv   r   r%  )rl   )
r,   r$  r-   r%  rV   rv   rW   rv   r   r%  )
r,   r$  r-   r%  r`   r   r.   rv   r   dict)r,   r$  r-   r%  rx   r   r   r'  )NNN)
r,   r$  r   r&  r   r&  r   r&  r   r'  )r   r'  r   r   )r   r'  r  r   r  zPath | Noner   None)r   r(  )1r  
__future__r   r  r   r  r*   syspathlibr   typingr   r   insertr   __file__resolver
  probe_exe_scene_tablesr   r   r   summarize_script_handler_tabler	   r
   r   r   r  r  r   r   r   rD   r   r   r   r%   r0   r7   rM   rZ   rj   r   r   r   r   r  r!  __name__r   r    r   <module>r3     sH   R "     
   3tH~--/667 8 L L d d H~''*
Ul -#  ;A4<&> *.&**.	G	G&G $G (	G
 
GTEPcL 25d B, zF r    