Rework API for getting at instructions
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.hxx
1 #ifndef INCLUDE__BasicBlockWidget_hxx
2 #define INCLUDE__BasicBlockWidget_hxx
3
4 #include "gui/qt.hxx"
5 #include <vector>
6 #include <cassert>
7 #include <tuple>
8 #include <array>
9 #include <memory>
10 #include <log4cxx/logger.h>
11 #include <list>
12
13 #include "disassembler/Instruction.hxx"
14
15 class Mainwindow;
16 class CustomQGraphicsTextItem;
17
18 class BasicBlock;
19
20 class RenameFunctionEvent;
21
22 class BasicBlockWidget : public QObject, public QGraphicsItem
23 {
24 Q_OBJECT
25 friend class CustomQGraphicsTextItem;
26 public:
27 BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
28
29 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
30 QWidget *widget);
31 QRectF boundingRect() const;
32 std::array<QPointF, 3> getExits() const;
33
34 void mouseMoveEvent(QGraphicsSceneMouseEvent * event)
35 { QGraphicsItem::mouseMoveEvent(event); scene()->update(); }
36
37 QPointF getEntry() const
38 { return mapToScene(QPointF(width/2, 0)); }
39
40 void addPrevious(BasicBlockWidget * widget)
41 { previous.push_back(widget); }
42
43 void addNext(BasicBlockWidget * left, BasicBlockWidget * right)
44 { next[0] = left; next[1] = right; }
45
46 BasicBlockWidget ** getNext()
47 { return next; }
48
49 QString getName() const
50 { return name; }
51 private:
52 void updateFunctionName(RenameFunctionEvent* event);
53 void populateWidget();
54
55 uint32_t width, height;
56 QString name;
57 std::unique_ptr<QGraphicsTextItem> _widget;
58 QTextTable* _table;
59 BasicBlock* block;
60 std::list<Instruction> instructions;
61 Mainwindow* mainwindow;
62 std::vector<BasicBlockWidget*> previous;
63 BasicBlockWidget* next[2];
64 log4cxx::LoggerPtr logger;
65 };
66
67 #endif