summaryrefslogtreecommitdiff
path: root/src/scriptengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/scriptengine.cpp')
-rw-r--r--src/scriptengine.cpp70
1 files changed, 39 insertions, 31 deletions
diff --git a/src/scriptengine.cpp b/src/scriptengine.cpp
index b65db70..e4c5c2e 100644
--- a/src/scriptengine.cpp
+++ b/src/scriptengine.cpp
@@ -39,6 +39,12 @@ void ScriptEngine::exec( Expression *pExpr )
39 39
40 for( Expression::iterator i = pExpr->begin(); i; i++ ) 40 for( Expression::iterator i = pExpr->begin(); i; i++ )
41 { 41 {
42// Bu::sio << (*i).eType << " - " << sNums << Bu::sio.nl;
43 if( ((*i).eType&Token::mMetaCmd) )
44 {
45 command( i );
46 continue;
47 }
42 switch( (*i).eType ) 48 switch( (*i).eType )
43 { 49 {
44 case Token::tNumber: 50 case Token::tNumber:
@@ -96,10 +102,6 @@ void ScriptEngine::exec( Expression *pExpr )
96 case Token::tNegate: 102 case Token::tNegate:
97 sNums.push( -sNums.peekPop() ); 103 sNums.push( -sNums.peekPop() );
98 break; 104 break;
99
100 case Token::tCommand:
101 command( i );
102 return;
103 } 105 }
104 } 106 }
105 107
@@ -109,35 +111,39 @@ void ScriptEngine::exec( Expression *pExpr )
109 111
110void ScriptEngine::command( Expression::iterator &i ) 112void ScriptEngine::command( Expression::iterator &i )
111{ 113{
112 Bu::String sCmd = *(*i).sVal; 114 switch( (*i).eType )
113 if( sCmd == "exit" || sCmd == "quit" )
114 { 115 {
115 bRunning = false; 116 case Token::tCmdExit:
116 return; 117 bRunning = false;
117 }
118 else if( sCmd == "scale" )
119 {
120 if( !(++i) )
121 {
122 if( sigError.isSet() )
123 sigError("You must provide a positive integer.");
124 return; 118 return;
125 } 119
126 int32_t iScale = strtol( (*i).sVal->getStr(), 0, 10 ); 120 case Token::tCmdScale:
127 if( iScale < 0 ) 121 {
128 { 122 if( !(++i) )
129 if( sigError.isSet() ) 123 {
130 sigError("You must provide a positive integer."); 124 if( sigError.isSet() )
131 return; 125 sigError("You must provide a positive integer.");
132 } 126 return;
133 if( sigMessage.isSet() ) 127 }
134 sigMessage(Bu::String("Changed scale to: %1").arg( iScale )); 128 int32_t iScale = strtol( (*i).sVal->getStr(), 0, 10 );
135 for( VarHash::iterator i = hVarState.begin(); i; i++ ) 129 if( iScale < 0 )
136 (*i).setScale( iScale ); 130 {
137 } 131 if( sigError.isSet() )
138 else if( sCmd == "radix" ) 132 sigError("You must provide a positive integer.");
139 { 133 return;
140 } 134 }
135 if( sigMessage.isSet() )
136 sigMessage(Bu::String("Changed scale to: %1").arg( iScale ));
137 for( VarHash::iterator i = hVarState.begin(); i; i++ )
138 (*i).setScale( iScale );
139 }
140 break;
141
142 case Token::tCmdRadix:
143 break;
144
145 case Token::tCmdExtended:
146 /*
141 else if( sCmd == "vars" ) 147 else if( sCmd == "vars" )
142 { 148 {
143 } 149 }
@@ -146,6 +152,8 @@ void ScriptEngine::command( Expression::iterator &i )
146 } 152 }
147 else 153 else
148 { 154 {
155 }*/
156 break;
149 } 157 }
150} 158}
151 159