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 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 12 | class NbRuntime : public QObject |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 13 | { |
| 14 | Q_OBJECT |
| 15 | |
| 16 | public: |
| 17 | explicit NbRuntime(QObject *parent = nullptr); |
| 18 | |
swissChili | a44bf72 | 2022-04-16 18:41:54 -0700 | [diff] [blame] | 19 | void reset(); |
| 20 | |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 21 | public slots: |
| 22 | void queueCell(Cell *cell); |
| 23 | void unqueueCell(Cell *cell); |
| 24 | |
| 25 | signals: |
| 26 | void cellFinishedRunning(Cell *cell, RuntimeResult result); |
swissChili | ece1ac8 | 2022-02-25 11:20:42 -0800 | [diff] [blame] | 27 | void cellFailedToParse(Cell *cell, ParseResult result, Parser parser); |
swissChili | d85daa9 | 2022-02-24 15:29:02 -0800 | [diff] [blame] | 28 | void cellWaiting(Cell *cell); |
| 29 | void cellRunning(Cell *cell); |
| 30 | void cellQuit(Cell *cell); |
| 31 | |
| 32 | protected: |
| 33 | void evalRemaining(); |
| 34 | |
| 35 | Evaluator _eval; |
| 36 | QQueue<Cell *> _cells; |
| 37 | Cell *_running = nullptr; |
| 38 | VarContext _ctx; |
| 39 | }; |