blob: d98daa3e2e01ed3f36e581fc6c6941d7b2b8b3c0 [file] [log] [blame]
swissChilid85daa92022-02-24 15:29:02 -08001#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
swissChili732628e2022-02-25 10:35:56 -080012class NbRuntime : public QObject
swissChilid85daa92022-02-24 15:29:02 -080013{
14 Q_OBJECT
15
16public:
17 explicit NbRuntime(QObject *parent = nullptr);
18
swissChilia44bf722022-04-16 18:41:54 -070019 void reset();
20
swissChilid85daa92022-02-24 15:29:02 -080021public slots:
22 void queueCell(Cell *cell);
23 void unqueueCell(Cell *cell);
24
25signals:
26 void cellFinishedRunning(Cell *cell, RuntimeResult result);
swissChiliece1ac82022-02-25 11:20:42 -080027 void cellFailedToParse(Cell *cell, ParseResult result, Parser parser);
swissChilid85daa92022-02-24 15:29:02 -080028 void cellWaiting(Cell *cell);
29 void cellRunning(Cell *cell);
30 void cellQuit(Cell *cell);
31
32protected:
33 void evalRemaining();
34
35 Evaluator _eval;
36 QQueue<Cell *> _cells;
37 Cell *_running = nullptr;
38 VarContext _ctx;
39};