diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-12-30 13:11:35 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-12-30 13:11:35 -0700 |
commit | f2ee67558acbe3c418a7558587b56158d593d88d (patch) | |
tree | d0b306fc26679fee672df740acdbdc0ede3c50dd /src/gamestate.cpp | |
parent | e112d781ea5ffc4186e7d70dba595b5a233335a8 (diff) | |
download | stage-f2ee67558acbe3c418a7558587b56158d593d88d.tar.gz stage-f2ee67558acbe3c418a7558587b56158d593d88d.tar.bz2 stage-f2ee67558acbe3c418a7558587b56158d593d88d.tar.xz stage-f2ee67558acbe3c418a7558587b56158d593d88d.zip |
return, exit, lists added. You can't index them.
They're linked lists right now, maybe that's not really what I want
long-term, but it'll work for now...
Diffstat (limited to 'src/gamestate.cpp')
-rw-r--r-- | src/gamestate.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/gamestate.cpp b/src/gamestate.cpp index fa014ac..d45d53c 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp | |||
@@ -9,7 +9,8 @@ | |||
9 | using namespace Bu; | 9 | using namespace Bu; |
10 | 10 | ||
11 | GameState::GameState( Game *pGame ) : | 11 | GameState::GameState( Game *pGame ) : |
12 | pGame( pGame ) | 12 | pGame( pGame ), |
13 | bRunning( true ) | ||
13 | { | 14 | { |
14 | } | 15 | } |
15 | 16 | ||
@@ -73,7 +74,8 @@ void GameState::execCommand( const Bu::String &sCmd ) | |||
73 | { | 74 | { |
74 | if( !pGame->execCommand( *this, lCmd ) ) | 75 | if( !pGame->execCommand( *this, lCmd ) ) |
75 | { | 76 | { |
76 | throw Bu::ExceptionBase("No such command exists."); | 77 | sio << "I don't understand that command." << sio.nl; |
78 | return; | ||
77 | } | 79 | } |
78 | } | 80 | } |
79 | } | 81 | } |
@@ -215,6 +217,12 @@ Bu::StringList GameState::tokenize( const Bu::String &sSrc ) | |||
215 | return lRet; | 217 | return lRet; |
216 | } | 218 | } |
217 | 219 | ||
220 | void GameState::exit() | ||
221 | { | ||
222 | bRunning = false; | ||
223 | bEscape = true; | ||
224 | } | ||
225 | |||
218 | Variable GameState::popDeref() | 226 | Variable GameState::popDeref() |
219 | { | 227 | { |
220 | Variable v = lStack.peekPop(); | 228 | Variable v = lStack.peekPop(); |
@@ -420,6 +428,17 @@ void GameState::parse( const AstBranch::NodeList &lCode ) | |||
420 | } | 428 | } |
421 | break; | 429 | break; |
422 | 430 | ||
431 | case AstNode::tReturn: | ||
432 | return; | ||
433 | break; | ||
434 | |||
435 | case AstNode::tAppend: | ||
436 | { | ||
437 | Variable v = popDeref(); | ||
438 | lStack.peek() += v; | ||
439 | } | ||
440 | break; | ||
441 | |||
423 | // tLeafLiteral | 442 | // tLeafLiteral |
424 | case AstNode::tVarName: | 443 | case AstNode::tVarName: |
425 | case AstNode::tLiteral: | 444 | case AstNode::tLiteral: |
@@ -435,6 +454,9 @@ void GameState::parse( const AstBranch::NodeList &lCode ) | |||
435 | 454 | ||
436 | // tBranch | 455 | // tBranch |
437 | case AstNode::tScope: | 456 | case AstNode::tScope: |
457 | throw Bu::ExceptionBase("Scope? that shouldn't be here..."); | ||
458 | break; | ||
459 | |||
438 | case AstNode::tIf: | 460 | case AstNode::tIf: |
439 | { | 461 | { |
440 | AstBranch::NodeList lIf = | 462 | AstBranch::NodeList lIf = |
@@ -488,7 +510,7 @@ void GameState::parse( const AstBranch::NodeList &lCode ) | |||
488 | break; | 510 | break; |
489 | } | 511 | } |
490 | 512 | ||
491 | if( bEscape ) | 513 | if( bEscape || !bRunning ) |
492 | { | 514 | { |
493 | return; | 515 | return; |
494 | } | 516 | } |