summaryrefslogtreecommitdiff
path: root/src/gamestate.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2011-12-30 13:11:35 -0700
committerMike Buland <eichlan@xagasoft.com>2011-12-30 13:11:35 -0700
commitf2ee67558acbe3c418a7558587b56158d593d88d (patch)
treed0b306fc26679fee672df740acdbdc0ede3c50dd /src/gamestate.cpp
parente112d781ea5ffc4186e7d70dba595b5a233335a8 (diff)
downloadstage-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.cpp28
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 @@
9using namespace Bu; 9using namespace Bu;
10 10
11GameState::GameState( Game *pGame ) : 11GameState::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
220void GameState::exit()
221{
222 bRunning = false;
223 bEscape = true;
224}
225
218Variable GameState::popDeref() 226Variable 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 }