コード例 #1
0
ファイル: instructions.py プロジェクト: bchretien/voidwalker
    def draw(self, terminal, width):
        table = Table()
        for address, instruction in self._instruction_listing.instructions():
            row = Row()

            const_face = '%(face-normal)s'
            if address == self._program_counter:
                const_face = '%(face-underlined)s'
            row.add_cell(Cell('%s0x%016lX:' % (const_face, address)))

            if instruction.symbol() is not None:
                identifier = ['%(face-identifier)s', instruction.symbol(), ':']
                row.add_cell(Cell(''.join(identifier)))
            else:
                row.add_cell(Cell())

            hex_string = [('%02X' % ord(i))
                          for i in instruction.opcode()
                          if i is not None]
            row.add_cell(Cell('%s%s' % (const_face, ' '.join(hex_string))))

            row.add_cell(Cell('%s%s' % ('%(face-statement)s',
                                        instruction.mnemonic())))

            if instruction.operands() is not None:
                operands = self._fmt_operands(instruction.operands())
                row.add_cell(Cell(operands))
            else:
                row.add_cell(Cell())

            table.add_row(row)

        table.draw(terminal, width)
コード例 #2
0
    def _create_registers_section(self, previous_context, context):
        registers_section = Section('registers')
        for _, register_dict in context.registers():
            reg_size = 0
            for name in register_dict.keys():
                reg_size = max(reg_size, len(name))

            table = Table()
            for name, register in register_dict.items():
                contents = [
                    ('%(face-identifier)s' + (('%%-%ds: ' % reg_size) % name))
                ]

                value = register.value()
                face = '%(face-constant)s'
                if previous_context.register(register.name()).value() != value:
                    face = '%(face-special)s'

                if value is not None:
                    contents += [('%s%s' % (face, register.str()))]

                else:
                    contents += [
                        ('%(face-comment)s' + (' %(register)s ' % {
                            'register': register.str()
                        }))
                    ]

                cell = Cell(''.join(contents))
                table.add_cell(cell)

            registers_section.add_component(table)

        return registers_section
コード例 #3
0
ファイル: context.py プロジェクト: Staphylo/voidwalker
    def _create_registers_section(self, previous_context, context):
        registers_section = Section('registers')
        for _, register_dict in context.registers():
            reg_size = 0
            for name in register_dict.keys():
                reg_size = max(reg_size, len(name))

            table = Table()
            for name, register in register_dict.items():
                contents = [('%(face-identifier)s' +
                             (('%%-%ds: ' % reg_size) % name))]

                value = register.value()
                face = '%(face-constant)s'
                if previous_context.register(register.name()).value() != value:
                    face = '%(face-special)s'

                if value is not None:
                    contents += [('%s%s' % (face, register.str()))]

                else:
                    contents += [('%(face-comment)s' +
                                  (' %(register)s ' %
                                   {'register': register.str()}))]

                cell = Cell(''.join(contents))
                table.add_cell(cell)

            registers_section.add_component(table)

        return registers_section
コード例 #4
0
            def execute(self, terminal, *_):
                table = Table()
                for name, snippet in snippet_repository.snippets():
                    row = Row()
                    row.add_cell(Cell('%s%s' % ('%(face-identifier)s', name)))
                    row.add_cell(Cell('%s%s' % ('%(face-comment)s',
                                                snippet.description())))
                    table.add_row(row)

                section = Section('snippets')
                section.add_component(table)
                section.draw(terminal, terminal.width())
コード例 #5
0
    def draw(self, terminal, width):
        table = Table()

        line_len = 16
        if width < 100:
            line_len = 8

        address = self._data_chunk.address()
        for line in grouper(line_len, self._data_chunk.buffer()):
            hex_string = []
            ascii_string = []
            for octuple in grouper(8, line):
                for quadruple in grouper(4, octuple):
                    hex_string += [(' %02X' % ord(i))
                                   for i in quadruple
                                   if i is not None]
                    filtered = ''.join([x.translate(self._ascii_filter)
                                        for x in quadruple
                                        if x is not None])
                    ascii_string += filtered.replace('%', '%%')

                hex_string += ['  ']
                ascii_string += ['  ']

            row = Row()
            row.add_cell(Cell('0x%016X:' % address))
            row.add_cell(Cell(''.join(hex_string)))
            row.add_cell(Cell(''.join(ascii_string)))
            table.add_row(row)

            address += line_len

        table.draw(terminal, width)
コード例 #6
0
ファイル: instructions.py プロジェクト: xwlan/voidwalker
    def draw(self, terminal, width):
        table = Table()
        for address, instruction in self._instruction_listing.instructions():
            row = Row()

            const_face = '%(face-normal)s'
            if address == self._program_counter:
                const_face = '%(face-underlined)s'
            row.add_cell(Cell('%s0x%016lX:' % (const_face, address)))

            if instruction.symbol() is not None:
                identifier = ['%(face-identifier)s', instruction.symbol(), ':']
                row.add_cell(Cell(''.join(identifier)))
            else:
                row.add_cell(Cell())

            hex_string = [('%02X' % ord(i)) for i in instruction.opcode()
                          if i is not None]
            row.add_cell(Cell('%s%s' % (const_face, ' '.join(hex_string))))

            row.add_cell(
                Cell('%s%s' % ('%(face-statement)s', instruction.mnemonic())))

            if instruction.operands() is not None:
                operands = self._fmt_operands(instruction.operands())
                row.add_cell(Cell(operands))
            else:
                row.add_cell(Cell())

            table.add_row(row)

        table.draw(terminal, width)