Example #1
0
 def __str__(self):
     L = []
     n = len(self)
     if conf.getboolean('block', 'header'):
         L.append('# --- block %s ---' % self.name)
     if conf.getboolean('block', 'bytecode'):
         bcs = ["'%s'" % (i.bytes.encode('hex')) for i in self]
         pad = conf.getint('block', 'padding') or 0
         maxlen = max(map(len, bcs)) + pad
         bcs = [s.ljust(maxlen) for s in bcs]
     else:
         bcs = [''] * n
     ins = [('{:<10}'.format(i.address), i.formatter(i)) for i in self]
     for j in range(n):
         L.append('%s %s %s' % (ins[j][0], bcs[j], ins[j][1]))
     return '\n'.join(L)
Example #2
0
 def __str__(self):
     L = []
     n = len(self)
     if conf.getboolean('block','header'):
         L.append('# --- block %s ---' % self.name)
     if conf.getboolean('block','bytecode'):
         bcs = [ "'%s'"%(i.bytes.encode('hex')) for i in self ]
         pad = conf.getint('block','padding') or 0
         maxlen = max(map(len,bcs))+pad
         bcs = [ s.ljust(maxlen) for s in bcs ]
     else:
         bcs = ['']*n
     ins = [ ('{:<10}'.format(i.address),i.formatter(i)) for i in self ]
     for j in range(n):
         L.append('%s %s %s'%(ins[j][0],bcs[j],ins[j][1]))
     return '\n'.join(L)
Example #3
0
 def _vltable(self, **kargs):
     T = vltable(**kargs)
     n = len(self.of.instr)
     for i in self.of.instr:
         ins2 = i.toks()
         if isinstance(ins2, str): ins2 = [(Token.Literal, ins2)]
         ins = [(Token.Address, '{:<10}'.format(i.address)),
                (Token.Column, ''),
                (Token.Literal, "'%s'" % (i.bytes.encode('hex'))),
                (Token.Column, '')]
         T.addrow(ins + ins2)
     if conf.getboolean('block', 'bytecode'):
         pad = conf.getint('block', 'padding') or 0
         T.colsize[1] += pad
     if conf.getboolean('block', 'header'):
         T.header = ('# --- block %s ---' % self.of.name).ljust(
             T.width, '-')
     if conf.getboolean('block', 'footer'):
         T.footer = '-' * T.width
     return T