#ifndef QWADB_H #define QWADB_H #include #include #include #include #include #include "ui_qwadb.h" #include "wasm.h" QT_BEGIN_NAMESPACE namespace Ui { class QWadb; } QT_END_NAMESPACE struct QWadbLinear { WasmType type; }; Q_DECLARE_METATYPE(QWadbLinear); class QWadb : public QMainWindow { Q_OBJECT public: QWadb(const QCoreApplication &app, QWidget *parent = nullptr); private: struct request { enum class type {global, local, param, bkpt, linear} type; varuint32 index, rindex; QVariant v; }; void open(const QString &path); int trap(const QList &frame); int ok(const QList &frame); int parse(const QByteArray &frame); int process(const QByteArray &frame); QVariant parse_value(const QByteArray &v, WasmType type) const; int parse_global(const QList ¶ms) const; int parse_param(const QList ¶ms) const; int parse_local(const QList ¶ms) const; int parse_linear(const QList ¶ms) const; int push(const request &r); int pop(request &r); typedef int (QWadb::*stepfn)(char); int getlf(char b); int getsync(char b); int write(const QByteArray &ba); const char *to_fmt(WasmType type) const; const char *to_string(WasmType type) const; int from_string(const QString &s, WasmType &type) const; request lastreq; bool connected; QTcpSocket socket; QByteArray frame; QQueue reqs; stepfn step; Ui::QWadb ui; Wasm w; signals: void sendreq(void); private slots: void disconnected(void); }; #endif