blob: 7a8f81aa4e88dacb5d1b2cc3c032560db5e1b92b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#ifndef GAME_STATE_H
#define GAME_STATE_H
#include "astbranch.h"
#include "variable.h"
#include "scope.h"
class Game;
class GameState
{
public:
GameState( Game *pGame );
virtual ~GameState();
void parse( class AstBranch *pAst );
Variable pop() { return lStack.peekPop(); }
void push( const Variable &v ) { lStack.push( v ); }
void callFunction( const Bu::String &sName );
enum ScopeId
{
sidLocal,
sidGlobal,
sidPlayer,
sidSituation
};
Variable getVariable( const Bu::String &sName, ScopeId id=sidLocal );
void setVariable( const Bu::String &sName, const Variable &v, ScopeId id=sidLocal );
private:
void parse( const AstBranch::NodeList &lCode );
private:
typedef Bu::List<Scope *> ScopeList;
typedef Bu::Hash<Bu::String, Scope *> ScopeHash;
Game *pGame;
Scope sGlobal;
Scope sPlayer;
ScopeList lsLocal;
ScopeHash hsSituation;
Bu::String sCurSituation;
VariableList lStack;
};
#endif
|