ó
™^c           @   sx   d  d l  Z  d d d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 d d „  ƒ  YZ d S(   iÿÿÿÿNt   SectionFlagsc           B   sJ   e  Z d  Z d Z d Z d Z d Z d Z d Z d Z	 d Z
 d	 Z d
 Z RS(   i    i@   i€   i   i   i   i   i   i    i   @I   €    (   t   __name__t
   __module__t   codet   initialized_datat   uninitialized_datat   extended_relocationst   discardablet   uncachedt   unpagedt   sharedt
   executablet   readablet   writable(    (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR       s   t   Sectionc           B   sà   e  Z d  Z i d d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z d „  e j e ƒ Dƒ Z d Z d$ d „ Z	 e
 d  „  ƒ Z e
 d! „  ƒ Z e j d" „  ƒ Z d$ d$ d# „ Z RS(%   i(   i   i   i    i   i  0 i   i  @ i   i  P i   i  ` i    i  p i@   i  € i€   i  � i   i    i   i  ° i   i  À i   i  Ð i   i  à i    c         C   s   i  |  ] \ } } | | “ q S(    (    (   t   .0t	   alignmentt   flag(    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pys
   <dictcomp>5   s   	 i  ð c         C   sÉ   d d l  m } t | t ƒ s8 t d t | ƒ ƒ ‚ n  | | ƒ s] t d t | ƒ ƒ ‚ n  t t |  ƒ j ƒ  | |  _ | t j	 @t j
 d B|  _ | d  k	 r­ | |  _ n  t ƒ  |  _ t ƒ  |  _ d  S(   Niÿÿÿÿ(   t	   is_uint32s   Section name %s is not a strings;   Flags %s are not representable as a 32-bit unsigned integeri   (   t   peachpy.utilR   t
   isinstancet   strt	   TypeErrort   superR   t   __init__t   namet   _alignment_maskt   _alignment_flag_mapt   flagst   NoneR   t   listt   relocationst	   bytearrayt   content(   t   selfR   R   R   R   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR   9   s    	c         C   s   t  |  j ƒ S(   N(   t   lenR!   (   R"   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyt   content_sizeK   s    c         C   s   t  j j |  j t  j @d ƒ S(   Ni   (   R   t   _flag_alignment_mapt   getR   R   (   R"   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR   O   s    c         C   sÀ   d d l  m } | | ƒ s5 t d t | ƒ ƒ ‚ n  | d k  rT t d | ƒ ‚ n  | | d @d k r{ t d | ƒ ‚ n  | t j k r� t d | ƒ ‚ n  |  j t j @t j | B|  _ d  S(	   Niÿÿÿÿ(   t   is_ints   Alignment %s is not an integeri    s&   Alignment %d is not a positive integeri   s    Alignment %d is not a power of 2s-   Alignment %d exceeds maximum alignment (8192)(	   R   R'   R   R   t
   ValueErrorR   R   R   R   (   R"   R   R'   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR   S   s    c         C   sQ  d d l  m } t | | ƒ s% t ‚ t | t ƒ s: t ‚ | d  k rO d } n  | d  k rd d } n  d } d } y | j |  j d ƒ }	 Wn: t k
 rÅ | |  j }
 | j d t	 |
 ƒ d ƒ }	 n X|	 | j
 |  j ƒ | j
 | ƒ | j
 |  j ƒ | j
 | ƒ | j
 | ƒ | j
 | ƒ | j t |  j ƒ ƒ | j | ƒ | j
 |  j ƒ S(   Niÿÿÿÿ(   t   Encoderi    i   t   /(   t   peachpy.encoderR)   R   t   AssertionErrort   dictR   t   fixed_stringR   R(   R   t   uint32R$   t   uint16R#   R   R   (   R"   t   encodert   name_index_mapt   offsett   relocations_offsett   addressR)   t   line_numbers_offsett   line_numbers_countt   name_8_bytest
   name_index(    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyt   encode_header`   s     		 	zN(   R   R   t   header_sizeR   t   sixt	   iteritemsR%   R   R   R   t   propertyR$   R   t   setterR:   (    (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR   !   s.   
t   TextSectionc           B   s   e  Z d  d d „ Z RS(   s   .textc         C   s1   t  t |  ƒ j | t j t j Bt j B| ƒ d  S(   N(   R   R@   R   R    R   R   R   (   R"   R   R   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR   }   s    N(   R   R   R   R   (    (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR@   |   s   t   ReadOnlyDataSectionc           B   s   e  Z d  d d „ Z RS(   s   .rdatac         C   s*   t  t |  ƒ j | t j t j B| ƒ d  S(   N(   R   RA   R   R    R   R   (   R"   R   R   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR   „   s    N(   R   R   R   R   (    (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyRA   ƒ   s   t   StringTablec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s   t  ƒ  |  _ d |  _ d  S(   Ni   (   R-   t   _stringst   size(   R"   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyR   ‹   s    c         C   so   d d  l  } | |  j k r& |  j | S|  j } | |  j | <| j | d ƒ } |  j t | ƒ d 7_ | Sd  S(   Niÿÿÿÿs   utf-8i   (   t   codecsRC   RD   t   encodeR#   (   R"   t   stringRE   t   string_indext
   bytestring(    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyt   add�   s    	c         C   st   d d  l  } d d  l } | j j j |  j ƒ } x= t |  j d |  j j ƒD]  } | | j	 | d ƒ d 7} qL W| S(   Niÿÿÿÿt   keyt   utf8s    (
   RE   R+   R1   R)   t   uint32leRD   t   sortedRC   R&   RF   (   R"   RE   t   peachpyRI   RG   (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyRF   ›   s    "(   R   R   R   RJ   RF   (    (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyRB   Š   s   		(    (    (   R<   R    t   objectR   R@   RA   RB   (    (    (    sK   /torch/pytorch/third_party/python-peachpy/peachpy/formats/mscoff/section.pyt   <module>   s
   [