diff options
Diffstat (limited to 'src/gamebuilder.cpp')
-rw-r--r-- | src/gamebuilder.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/gamebuilder.cpp b/src/gamebuilder.cpp index 3696495..44fd6c1 100644 --- a/src/gamebuilder.cpp +++ b/src/gamebuilder.cpp | |||
@@ -1,9 +1,15 @@ | |||
1 | #include "gamebuilder.h" | 1 | #include "gamebuilder.h" |
2 | #include <bu/sio.h> | 2 | #include <bu/sio.h> |
3 | 3 | ||
4 | #include "astbranch.h" | ||
5 | #include "astleaf.h" | ||
6 | #include "astleafliteral.h" | ||
7 | |||
4 | using namespace Bu; | 8 | using namespace Bu; |
5 | 9 | ||
6 | GameBuilder::GameBuilder() | 10 | GameBuilder::GameBuilder() : |
11 | pCurNode( NULL ), | ||
12 | pCurRoot( NULL ) | ||
7 | { | 13 | { |
8 | } | 14 | } |
9 | 15 | ||
@@ -24,12 +30,14 @@ void GameBuilder::setGameParam( const Bu::String &sName ) | |||
24 | 30 | ||
25 | void GameBuilder::beginFunction( const Bu::String &sName ) | 31 | void GameBuilder::beginFunction( const Bu::String &sName ) |
26 | { | 32 | { |
33 | pCurNode = pCurRoot = new AstBranch( AstNode::tScope ); | ||
34 | |||
27 | sio << "New function: " << sName << sio.nl; | 35 | sio << "New function: " << sName << sio.nl; |
28 | } | 36 | } |
29 | 37 | ||
30 | void GameBuilder::endFunction() | 38 | void GameBuilder::endFunction() |
31 | { | 39 | { |
32 | sio << "Function ended." << sio.nl; | 40 | sio << "Function ended: " << *pCurRoot << sio.nl; |
33 | } | 41 | } |
34 | 42 | ||
35 | void GameBuilder::beginSituation( const Bu::String &sName ) | 43 | void GameBuilder::beginSituation( const Bu::String &sName ) |
@@ -47,14 +55,29 @@ void GameBuilder::addParam( const Bu::String &sName ) | |||
47 | sio << " - Param added '" << sName << "'" << sio.nl; | 55 | sio << " - Param added '" << sName << "'" << sio.nl; |
48 | } | 56 | } |
49 | 57 | ||
50 | void GameBuilder::addNode( int iType ) | 58 | void GameBuilder::addNode( AstNode::Type iType ) |
51 | { | 59 | { |
52 | sio << " - Added type " << Fmt::hex() << iType << sio.nl; | 60 | sio << " - Added type " << Fmt::hex() << iType << sio.nl; |
61 | |||
62 | switch( iType&AstNode::tTypeMask ) | ||
63 | { | ||
64 | case AstNode::tBranch: | ||
65 | pCurNode = (AstBranch *)pCurNode->addNode( new AstBranch( iType ) ); | ||
66 | break; | ||
67 | |||
68 | case AstNode::tLeaf: | ||
69 | pCurNode->addNode( new AstLeaf( iType ) ); | ||
70 | break; | ||
71 | } | ||
53 | } | 72 | } |
54 | 73 | ||
55 | void GameBuilder::addLiteral( const Variable &v ) | 74 | void GameBuilder::addLiteral( const Variable &v ) |
56 | { | 75 | { |
57 | setLiteral( v ); | 76 | setLiteral( v ); |
77 | if( pCurNode ) | ||
78 | { | ||
79 | pCurNode->addNode( new AstLeafLiteral( v ) ); | ||
80 | } | ||
58 | sio << " - Added literal " << v << sio.nl; | 81 | sio << " - Added literal " << v << sio.nl; |
59 | } | 82 | } |
60 | 83 | ||