ó
Ð:Nc           @   s   d    Z  d   Z d   Z d S(   c         C   s   g  } xy t  |   D]k \ } } t |  } t |  d } | d k rT d | } n  | d d k rq | d 7} n  | j |  q Wd j |  j   S(   sN    Convert the raw data in 'd' to an hex string with a space every 4 bytes.
    i   i   t   0i   i   t    t    (   t	   enumeratet   ordt   hext   appendt   joint   strip(   t   dt   bytest   it   ct   bytet   hex_byte(    (    sL   /Volumes/Sandbox/llvm/3.0-release/final/llvm.src/test/Scripts/common_dump.pyt	   dataToHex   s    c         C   sē   g  } x t  |   D] \ } } t |  } t |  d } | d k rT d | } n  | d d k rq d | } n  | d d k r | d 7} n  | j |  q Wd	 j |  j   S(
   sŅ    Convert the raw data in 'd' to an hex string with a space every 4 bytes.
    Each 4byte number is prefixed with 0x for easy sed/rx
    Fixme: convert all MC tests to use this routine instead of the above
    i   i   R    i   i    t   0xi   R   R   (   R   R   R   R   R   R   (   R	   R
   R   R   R   R   (    (    sL   /Volumes/Sandbox/llvm/3.0-release/final/llvm.src/test/Scripts/common_dump.pyt   dataToHexUnified   s    c         C   sb   |  \ } } d | k o' d | >k  n s2 t   | d | >d @} d d | d d } | | S(   s  
    1. do not print 'L'
    2. Handle negatives and large numbers by mod (2^numBits)
    3. print fixed length, prepend with zeros.
       Length is exactly 2+(numBits/4)
    4. Do print 0x Why?
       so that they can be easily distinguished using sed/rx
    i    i   s   0x%0s   %di   t   x(   t   AssertionError(   t   valPairt   valt   numBitst   newFmt(    (    sL   /Volumes/Sandbox/llvm/3.0-release/final/llvm.src/test/Scripts/common_dump.pyt   HexDump"   s
    	&N(   R   R   R   (    (    (    sL   /Volumes/Sandbox/llvm/3.0-release/final/llvm.src/test/Scripts/common_dump.pyt   <module>   s   		