From 549069762ccc35352186eb4fe1922883a0c4f213 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Jan 2012 23:50:00 -0700 Subject: Return seems to be fixed. --- src/gamestate.cpp | 7 ++++++- src/gamestate.h | 1 + test.stage | 25 ++++++++++++++++++++++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/gamestate.cpp b/src/gamestate.cpp index 2032d5c..57dbe2f 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -10,7 +10,8 @@ using namespace Bu; GameState::GameState( Game *pGame ) : pGame( pGame ), - bRunning( true ) + bRunning( true ), + bReturnOnly( false ) { } @@ -498,6 +499,8 @@ void GameState::parse( const AstBranch::NodeList &lCode ) break; case AstNode::tReturn: + bReturnOnly = true; + bEscape = true; return; break; @@ -536,6 +539,8 @@ void GameState::parse( const AstBranch::NodeList &lCode ) dynamic_cast(*i) ->getValue().getString() ); + bReturnOnly = false; + bEscape = false; break; // tBranch diff --git a/src/gamestate.h b/src/gamestate.h index 5c47ce0..9e7a060 100644 --- a/src/gamestate.h +++ b/src/gamestate.h @@ -54,6 +54,7 @@ private: bool bEscape; bool bRunning; + bool bReturnOnly; Bu::String sPrompt; VariableList lStack; diff --git a/test.stage b/test.stage index 42529af..b963b2b 100644 --- a/test.stage +++ b/test.stage @@ -13,13 +13,32 @@ global } } +function subfunction() +{ + if true then + { + return(); + } + display("subfunction()"); +} + +function hello() +{ + if true == true then + { + subfunction(); + display("Yeah!"); + return(); + } + display("hello()"); +} + situation <> { setup { - global.stuff = {'count': 1}; - global.stuff['count'] += 5; - display( global.stuff['count'] ); + hello(); + display("situation"); exit(); } -- cgit v1.2.3