Beispiel #1
0
 def __init__(self, x, opc, first_line=None, current_offset=None):
     self.codeobj = co = get_code_object(x)
     if first_line is None:
         self.first_line = co.co_firstlineno
         self._line_offset = 0
     else:
         self.first_line = first_line
         self._line_offset = first_line - co.co_firstlineno
     self._cell_names = co.co_cellvars + co.co_freevars
     self._linestarts = dict(opc.findlinestarts(co))
     self._original_object = x
     self.opc = opc
     self.opnames = opc.opname
     self.current_offset = current_offset
Beispiel #2
0
 def __init__(self, x, opc, first_line=None, current_offset=None):
     self.codeobj = co = get_code_object(x)
     if first_line is None:
         self.first_line = co.co_firstlineno
         self._line_offset = 0
     else:
         self.first_line = first_line
         self._line_offset = first_line - co.co_firstlineno
     self._cell_names = co.co_cellvars + co.co_freevars
     self._linestarts = dict(opc.findlinestarts(co))
     self._original_object = x
     self.opc = opc
     self.opnames = opc.opname
     self.current_offset = current_offset
Beispiel #3
0
    def get_instructions(self, x, first_line=None):
        """Iterator for the opcodes in methods, functions or code

        Generates a series of Instruction named tuples giving the details of
        each operations in the supplied code.

        If *first_line* is not None, it indicates the line number that should
        be reported for the first source line in the disassembled code.
        Otherwise, the source line information (if any) is taken directly from
        the disassembled code object.
        """
        co = get_code_object(x)
        cell_names = co.co_cellvars + co.co_freevars
        linestarts = dict(self.opc.findlinestarts(co))
        if first_line is not None:
            line_offset = first_line - co.co_firstlineno
        else:
            line_offset = 0
        return get_instructions_bytes(co.co_code, self.opc, co.co_varnames,
                                      co.co_names, co.co_consts, cell_names, linestarts,
                                      line_offset)
Beispiel #4
0
    def get_instructions(self, x, first_line=None):
        """Iterator for the opcodes in methods, functions or code

        Generates a series of Instruction named tuples giving the details of
        each operations in the supplied code.

        If *first_line* is not None, it indicates the line number that should
        be reported for the first source line in the disassembled code.
        Otherwise, the source line information (if any) is taken directly from
        the disassembled code object.
        """
        co = get_code_object(x)
        cell_names = co.co_cellvars + co.co_freevars
        linestarts = dict(self.opc.findlinestarts(co))
        if first_line is not None:
            line_offset = first_line - co.co_firstlineno
        else:
            line_offset = 0
        return get_instructions_bytes(co.co_code, self.opc, co.co_varnames,
                                      co.co_names, co.co_consts, cell_names, linestarts,
                                      line_offset)