summaryrefslogtreecommitdiff
path: root/src/scriptengine.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2016-12-01 15:51:52 -0700
committerMike Buland <eichlan@xagasoft.com>2016-12-01 15:51:52 -0700
commit5d59aa3e9dffe2912215335ce0b76c67ebbe5a4e (patch)
treefa4f7b73f912b0b5ff87280c0bc4dc118a82392d /src/scriptengine.h
parent17a39c19e5bff97c3b3d2bc888a3bb5ded7c1b96 (diff)
downloadclic-5d59aa3e9dffe2912215335ce0b76c67ebbe5a4e.tar.gz
clic-5d59aa3e9dffe2912215335ce0b76c67ebbe5a4e.tar.bz2
clic-5d59aa3e9dffe2912215335ce0b76c67ebbe5a4e.tar.xz
clic-5d59aa3e9dffe2912215335ce0b76c67ebbe5a4e.zip
Signals solve many problems.
The command structures will be changed, I think. I want the lexer to actually lex the command names into tokens, then the parser and the engine can both use them to update their state when necesarry. It will be less ambiguous and easier for both sides to stay synchronized.
Diffstat (limited to '')
-rw-r--r--src/scriptengine.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/scriptengine.h b/src/scriptengine.h
index 74924d6..b25c651 100644
--- a/src/scriptengine.h
+++ b/src/scriptengine.h
@@ -2,11 +2,12 @@
2#define SCRIPT_ENGINE_H 2#define SCRIPT_ENGINE_H
3 3
4#include "number.h" 4#include "number.h"
5#include "expression.h"
5 6
6#include <bu/hash.h> 7#include <bu/hash.h>
7#include <bu/list.h> 8#include <bu/list.h>
8#include <bu/string.h> 9#include <bu/string.h>
9 10#include <bu/signals.h>
10 11
11namespace Bu 12namespace Bu
12{ 13{
@@ -16,18 +17,31 @@ class Expression;
16 17
17class ScriptEngine 18class ScriptEngine
18{ 19{
20private:
21 typedef Bu::Hash<Bu::String, Number> VarHash;
22 typedef Bu::List<Number> NumStack;
23
19public: 24public:
20 ScriptEngine(); 25 ScriptEngine();
21 virtual ~ScriptEngine(); 26 virtual ~ScriptEngine();
22 27
23 Number exec( const Bu::String &sExpr ); 28 void exec( const Bu::String &sExpr );
24 Number exec( Bu::Stream &sInput ); 29 void exec( Bu::Stream &sInput );
25 Number exec( Expression *pExpr ); 30 void exec( Expression *pExpr );
31
32 bool isRunning() const { return bRunning; }
33
34public:
35 Bu::Signal1<void, const class Number &> sigNumResult;
36 Bu::Signal1<void, const Bu::String &> sigError;
37 Bu::Signal1<void, const Bu::String &> sigMessage;
38
39private:
40 void command( Expression::iterator &i );
26 41
27private: 42private:
28 typedef Bu::Hash<Bu::String, Number> VarHash;
29 typedef Bu::List<Number> NumStack;
30 VarHash hVarState; 43 VarHash hVarState;
44 bool bRunning;
31}; 45};
32 46
33#endif 47#endif