summaryrefslogtreecommitdiff
path: root/qwadb.h
diff options
context:
space:
mode:
Diffstat (limited to 'qwadb.h')
-rw-r--r--qwadb.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/qwadb.h b/qwadb.h
new file mode 100644
index 0000000..87335cf
--- /dev/null
+++ b/qwadb.h
@@ -0,0 +1,82 @@
+#ifndef QWADB_H
+#define QWADB_H
+
+#include <QByteArray>
+#include <QList>
+#include <QMainWindow>
+#include <QTcpSocket>
+#include <QQueue>
+#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<QByteArray> &frame);
+ int ok(const QList<QByteArray> &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<QByteArray> &params) const;
+ int parse_param(const QList<QByteArray> &params) const;
+ int parse_local(const QList<QByteArray> &params) const;
+ int parse_linear(const QList<QByteArray> &params) 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<request> reqs;
+ stepfn step;
+ Ui::QWadb ui;
+ Wasm w;
+
+signals:
+ void sendreq(void);
+
+private slots:
+ void disconnected(void);
+};
+
+#endif