eric7.UI.PythonDisViewer

Module implementing a widget to visualize the Python Disassembly for some Python sources.

Global Attributes

None

Classes

PythonDisViewer Class implementing a widget to visualize the Python Disassembly for some Python sources.
PythonDisViewerModes Class implementing the disassembly viewer operation modes.

Functions

linestarts Function to get the line starts for the given code object.
tryCompile Function to attempt to compile the given source, first as an expression and then as a statement if the first approach fails.


PythonDisViewer

Class implementing a widget to visualize the Python Disassembly for some Python sources.

Derived from

QWidget, Ui_PythonDisViewer

Class Attributes

CodeInfoRole
EndLineRole
StartLineRole

Class Methods

None

Methods

PythonDisViewer Constructor
__clearSelection Private method to clear all selected items.
__codeInfoContextMenuRequested Private slot to show the context menu of the code info widget.
__collapseAllCodeInfo Private slot to collapse all items of the code info widget.
__collapseAllDis Private slot to collapse all items of the disassembly widget.
__configure Private method to open the configuration dialog.
__createCodeInfo Private method to create a dictionary containing the code info data.
__createErrorItem Private method to create a top level error item.
__createInstructionItem Private method to create an item for the given instruction.
__createTitleItem Private method to create a title item.
__disContextMenuRequested Private slot to show the context menu of the disassembly widget.
__disItemClicked Private slot handling a user click on a Disassembly node item.
__disViewerStateChanged Private slot to toggle the display of the Disassembly viewer.
__disassembleObject Private method to disassemble the given code object recursively.
__editorChanged Private slot to handle a change of the current editor.
__editorLanguageChanged Private slot to handle a change of the editor language.
__editorLineChanged Private slot to handle a mouse button double click in the editor.
__editorSaved Private slot to reload the Disassembly after the connected editor was saved.
__expandAllCodeInfo Private slot to expand all items of the code info widget.
__expandAllDis Private slot to expand all items of the disassembly widget.
__lastEditorClosed Private slot to handle the last editor closed signal of the view manager.
__loadDIS Private method to generate the Disassembly from the source of the current editor and visualize it.
__resizeCodeInfoColumns Private method to resize the columns of the code info widget to suitable values.
__resizeDisColumns Private method to resize the columns of the disassembly widget to suitable values.
__selectChildren Private method to select children of the given item covering the given line number.
__selectItemForEditorLine Private slot to select the items corresponding with the cursor line of the current editor.
__showCodeInfo Private slot handling the context menu action to show code info.
__showCodeInfoData Private method to show the passed code info data.
__styleLabels Private method to style the info labels iaw.
__updateItemEndLine Private method to update an items end line based on its children.
clear Public method to clear the display.
createCodeInfoItems Function to create code info items for the given list.
hide Public slot to hide the DIS viewer.
preferencesChanged Public slot handling changes of the Disassembly viewer settings.
resizeEvent Protected method to handle resize events.
show Public slot to show the DIS viewer.
showDisassembly Public slot to receive a code disassembly from the debug client.
shutdown Public method to perform shutdown actions.

Static Methods

None

PythonDisViewer (Constructor)

PythonDisViewer(viewmanager, mode=PythonDisViewerModes.SOURCEDISASSEMBLY, parent=None)

Constructor

viewmanager (ViewManager)
reference to the viewmanager object
mode (int)
operation mode of the viewer
parent (QWidget)
reference to the parent widget

PythonDisViewer.__clearSelection

__clearSelection()

Private method to clear all selected items.

PythonDisViewer.__codeInfoContextMenuRequested

__codeInfoContextMenuRequested(coord)

Private slot to show the context menu of the code info widget.

coord (QPoint)
position of the mouse pointer

PythonDisViewer.__collapseAllCodeInfo

__collapseAllCodeInfo()

Private slot to collapse all items of the code info widget.

PythonDisViewer.__collapseAllDis

__collapseAllDis()

Private slot to collapse all items of the disassembly widget.

PythonDisViewer.__configure

__configure()

Private method to open the configuration dialog.

PythonDisViewer.__createCodeInfo

__createCodeInfo(co)

Private method to create a dictionary containing the code info data.

co (code)
reference to the code object to generate the info for
Return:
dictionary containing the code info data
Return Type:
dict

PythonDisViewer.__createErrorItem

__createErrorItem(error)

Private method to create a top level error item.

error (str)
error message
Return:
generated item
Return Type:
QTreeWidgetItem

PythonDisViewer.__createInstructionItem

__createInstructionItem(instr, parent, lasti=-1)

Private method to create an item for the given instruction.

instr (dis.Instruction)
instruction the item should be based on
parent (QTreeWidgetItem)
reference to the parent item
lasti (int)
index of the instruction of a traceback
Return:
generated item
Return Type:
QTreeWidgetItem

PythonDisViewer.__createTitleItem

__createTitleItem(title, line, parentItem)

Private method to create a title item.

title (str)
titel string for the item
line (int)
start line of the titled disassembly
parentItem (QTreeWidget or QTreeWidgetItem)
reference to the parent item
Return:
generated item
Return Type:
QTreeWidgetItem

PythonDisViewer.__disContextMenuRequested

__disContextMenuRequested(coord)

Private slot to show the context menu of the disassembly widget.

coord (QPoint)
position of the mouse pointer

PythonDisViewer.__disItemClicked

__disItemClicked(itm, _column)

Private slot handling a user click on a Disassembly node item.

itm (QTreeWidgetItem)
reference to the clicked item
_column (int)
column number of the click (unused)

PythonDisViewer.__disViewerStateChanged

__disViewerStateChanged(on)

Private slot to toggle the display of the Disassembly viewer.

on (bool)
flag indicating to show the Disassembly

PythonDisViewer.__disassembleObject

__disassembleObject(co, parentItem, parentName="", lasti=-1)

Private method to disassemble the given code object recursively.

co (code object)
code object to be disassembled
parentItem (QTreeWidget or QTreeWidgetItem)
reference to the parent item
parentName (str)
name of the parent code object
lasti (int)
index of the instruction of a traceback

PythonDisViewer.__editorChanged

__editorChanged(editor)

Private slot to handle a change of the current editor.

editor (Editor)
reference to the current editor

PythonDisViewer.__editorLanguageChanged

__editorLanguageChanged(editor)

Private slot to handle a change of the editor language.

editor (Editor)
reference to the editor which changed language

PythonDisViewer.__editorLineChanged

__editorLineChanged(editor, _lineno)

Private slot to handle a mouse button double click in the editor.

editor (Editor)
reference to the editor, that emitted the signal
_lineno (int)
line number of the editor's cursor (zero based) (unused)

PythonDisViewer.__editorSaved

__editorSaved(editor)

Private slot to reload the Disassembly after the connected editor was saved.

editor (Editor)
reference to the editor that performed a save action

PythonDisViewer.__expandAllCodeInfo

__expandAllCodeInfo()

Private slot to expand all items of the code info widget.

PythonDisViewer.__expandAllDis

__expandAllDis()

Private slot to expand all items of the disassembly widget.

PythonDisViewer.__lastEditorClosed

__lastEditorClosed()

Private slot to handle the last editor closed signal of the view manager.

PythonDisViewer.__loadDIS

__loadDIS()

Private method to generate the Disassembly from the source of the current editor and visualize it.

PythonDisViewer.__resizeCodeInfoColumns

__resizeCodeInfoColumns()

Private method to resize the columns of the code info widget to suitable values.

PythonDisViewer.__resizeDisColumns

__resizeDisColumns()

Private method to resize the columns of the disassembly widget to suitable values.

PythonDisViewer.__selectChildren

__selectChildren(itm, lineno)

Private method to select children of the given item covering the given line number.

itm (QTreeWidgetItem)
reference to the item
lineno (int)
line number to base the selection on

PythonDisViewer.__selectItemForEditorLine

__selectItemForEditorLine()

Private slot to select the items corresponding with the cursor line of the current editor.

PythonDisViewer.__showCodeInfo

__showCodeInfo()

Private slot handling the context menu action to show code info.

PythonDisViewer.__showCodeInfoData

__showCodeInfoData(codeInfo)

Private method to show the passed code info data.

codeInfo (dict)
dictionary containing the code info data

PythonDisViewer.__styleLabels

__styleLabels()

Private method to style the info labels iaw. selected colors.

PythonDisViewer.__updateItemEndLine

__updateItemEndLine(itm)

Private method to update an items end line based on its children.

itm (QTreeWidgetItem)
reference to the item to be updated

PythonDisViewer.clear

clear()

Public method to clear the display.

PythonDisViewer.createCodeInfoItems

createCodeInfoItems(infoList)

Function to create code info items for the given list.

title (str)
title string for the list
infoList (list of str)
list of info strings

PythonDisViewer.hide

hide()

Public slot to hide the DIS viewer.

PythonDisViewer.preferencesChanged

preferencesChanged()

Public slot handling changes of the Disassembly viewer settings.

PythonDisViewer.resizeEvent

resizeEvent(_evt)

Protected method to handle resize events.

_evt (QResizeEvent)
resize event (unused)

PythonDisViewer.show

show()

Public slot to show the DIS viewer.

PythonDisViewer.showDisassembly

showDisassembly(disassembly)

Public slot to receive a code disassembly from the debug client.

disassembly (dict)
dictionary containing the disassembly information

PythonDisViewer.shutdown

shutdown()

Public method to perform shutdown actions.

Up


PythonDisViewerModes

Class implementing the disassembly viewer operation modes.

Derived from

enum.Enum

Class Attributes

SOURCEDISASSEMBLY
TRACEBACK

Class Methods

None

Methods

None

Static Methods

None
Up


linestarts

linestarts(co, filename="", getall=True)

Function to get the line starts for the given code object.

co (code object or str)
reference to the compiled code object or the source code
filename (str)
name of the source file (optional)
getall (bool)
flag indicating to get all line starts recursively
Return:
list of lines starting some byte code instruction block
Return Type:
list of int
Up


tryCompile

tryCompile(source, name)

Function to attempt to compile the given source, first as an expression and then as a statement if the first approach fails.

source (str)
source code string to be compiled
name (str)
name of the file containing the source
Return:
compiled code
Return Type:
code object
Up