| 1297 | } |
| 1298 | |
| 1299 | int asCContext::SetArgAddress(asUINT arg, void *value) |
| 1300 | { |
| 1301 | if( m_status != asEXECUTION_PREPARED ) |
| 1302 | return asCONTEXT_NOT_PREPARED; |
| 1303 | |
| 1304 | if( arg >= (unsigned)m_initialFunction->parameterTypes.GetLength() ) |
| 1305 | { |
| 1306 | m_status = asEXECUTION_ERROR; |
| 1307 | return asINVALID_ARG; |
| 1308 | } |
| 1309 | |
| 1310 | // Verify the type of the argument |
| 1311 | asCDataType *dt = &m_initialFunction->parameterTypes[arg]; |
| 1312 | if( !dt->IsReference() && !dt->IsObjectHandle() ) |
| 1313 | { |
| 1314 | m_status = asEXECUTION_ERROR; |
| 1315 | return asINVALID_TYPE; |
| 1316 | } |
| 1317 | |
| 1318 | // Determine the position of the argument |
| 1319 | int offset = 0; |
| 1320 | if( m_initialFunction->objectType ) |
| 1321 | offset += AS_PTR_SIZE; |
| 1322 | |
| 1323 | // If function returns object by value an extra pointer is pushed on the stack |
| 1324 | if( m_returnValueSize ) |
| 1325 | offset += AS_PTR_SIZE; |
| 1326 | |
| 1327 | for( asUINT n = 0; n < arg; n++ ) |
| 1328 | offset += m_initialFunction->parameterTypes[n].GetSizeOnStackDWords(); |
| 1329 | |
| 1330 | // Set the value |
| 1331 | *(asPWORD*)(&m_regs.stackFramePointer[offset]) = (asPWORD)value; |
| 1332 | |
| 1333 | return 0; |
| 1334 | } |
| 1335 | |
| 1336 | int asCContext::SetArgObject(asUINT arg, void *obj) |
| 1337 | { |