swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <QObject> |
| 4 | #include <QThread> |
| 5 | #include <QQueue> |
| 6 | |
| 7 | #include "Cell.h" |
| 8 | #include "../Token.h" |
| 9 | #include "../Evaluator.h" |
| 10 | #include "../Parser.h" |
| 11 | |
| 12 | class NbRuntime : public QThread |
| 13 | { |
| 14 | Q_OBJECT |
| 15 | |
| 16 | public: |
| 17 | explicit NbRuntime(QObject *parent = nullptr); |
| 18 | |
| 19 | public slots: |
| 20 | void queueCell(Cell *cell); |
| 21 | void unqueueCell(Cell *cell); |
| 22 | |
| 23 | signals: |
| 24 | void cellFinishedRunning(Cell *cell, RuntimeResult result); |
| 25 | void cellFailedToParse(Cell *cell, ParseResult result); |
| 26 | void cellWaiting(Cell *cell); |
| 27 | void cellRunning(Cell *cell); |
| 28 | void cellQuit(Cell *cell); |
| 29 | |
| 30 | protected: |
| 31 | void evalRemaining(); |
| 32 | |
| 33 | Evaluator _eval; |
| 34 | QQueue<Cell *> _cells; |
| 35 | Cell *_running = nullptr; |
| 36 | VarContext _ctx; |
| 37 | }; |