interface
| 1202 | |
| 1203 | // interface |
| 1204 | int asCContext::Execute() |
| 1205 | { |
| 1206 | asASSERT( m_engine != 0 ); |
| 1207 | |
| 1208 | if( m_status != asEXECUTION_SUSPENDED && m_status != asEXECUTION_PREPARED ) |
| 1209 | { |
| 1210 | asCString str; |
| 1211 | str.Format(TXT_FAILED_IN_FUNC_s_s_d, "Execute", errorNames[-asCONTEXT_NOT_PREPARED], asCONTEXT_NOT_PREPARED); |
| 1212 | m_engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, str.AddressOf()); |
| 1213 | return asCONTEXT_NOT_PREPARED; |
| 1214 | } |
| 1215 | |
| 1216 | m_status = asEXECUTION_ACTIVE; |
| 1217 | |
| 1218 | asCThreadLocalData *tld = asPushActiveContext((asIScriptContext *)this); |
| 1219 | |
| 1220 | // Make sure there are not too many nested calls, as it could crash the application |
| 1221 | // by filling up the thread call stack |
| 1222 | if (tld->activeContexts.GetLength() > m_engine->ep.maxNestedCalls) |
| 1223 | SetInternalException(TXT_TOO_MANY_NESTED_CALLS); |
| 1224 | else if( m_regs.programPointer == 0 ) |
| 1225 | { |
| 1226 | if( m_currentFunction->funcType == asFUNC_DELEGATE ) |
| 1227 | { |
| 1228 | // Push the object pointer onto the stack |
| 1229 | asASSERT( m_regs.stackPointer - AS_PTR_SIZE >= m_stackBlocks[m_stackIndex] ); |
| 1230 | m_regs.stackPointer -= AS_PTR_SIZE; |
| 1231 | m_regs.stackFramePointer -= AS_PTR_SIZE; |
| 1232 | *(asPWORD*)m_regs.stackPointer = asPWORD(m_currentFunction->objForDelegate); |
| 1233 | |
| 1234 | // Make the call to the delegated object method |
| 1235 | m_currentFunction = m_currentFunction->funcForDelegate; |
| 1236 | } |
| 1237 | |
| 1238 | if( m_currentFunction->funcType == asFUNC_VIRTUAL || |
| 1239 | m_currentFunction->funcType == asFUNC_INTERFACE ) |
| 1240 | { |
| 1241 | // The currentFunction is a virtual method |
| 1242 | |
| 1243 | // Determine the true function from the object |
| 1244 | asCScriptObject *obj = *(asCScriptObject**)(asPWORD*)m_regs.stackFramePointer; |
| 1245 | if( obj == 0 ) |
| 1246 | { |
| 1247 | SetInternalException(TXT_NULL_POINTER_ACCESS); |
| 1248 | } |
| 1249 | else |
| 1250 | { |
| 1251 | asCObjectType *objType = obj->objType; |
| 1252 | asCScriptFunction *realFunc = 0; |
| 1253 | |
| 1254 | if( m_currentFunction->funcType == asFUNC_VIRTUAL ) |
| 1255 | { |
| 1256 | if( objType->virtualFunctionTable.GetLength() > (asUINT)m_currentFunction->vfTableIdx ) |
| 1257 | { |
| 1258 | realFunc = objType->virtualFunctionTable[m_currentFunction->vfTableIdx]; |
| 1259 | } |
| 1260 | } |
| 1261 | else |
no test coverage detected