internal
| 1264 | |
| 1265 | // internal |
| 1266 | void asCScriptFunction::ReleaseReferences() |
| 1267 | { |
| 1268 | asCArray<void*> ptrs; |
| 1269 | |
| 1270 | // Only count references if there is any bytecode |
| 1271 | if( scriptData && scriptData->byteCode.GetLength() ) |
| 1272 | { |
| 1273 | if( returnType.GetTypeInfo() ) |
| 1274 | { |
| 1275 | returnType.GetTypeInfo()->ReleaseInternal(); |
| 1276 | |
| 1277 | asCConfigGroup *group = engine->FindConfigGroupForTypeInfo(returnType.GetTypeInfo()); |
| 1278 | if( group != 0 ) group->Release(); |
| 1279 | } |
| 1280 | |
| 1281 | for( asUINT p = 0; p < parameterTypes.GetLength(); p++ ) |
| 1282 | if( parameterTypes[p].GetTypeInfo() ) |
| 1283 | { |
| 1284 | parameterTypes[p].GetTypeInfo()->ReleaseInternal(); |
| 1285 | |
| 1286 | asCConfigGroup *group = engine->FindConfigGroupForTypeInfo(parameterTypes[p].GetTypeInfo()); |
| 1287 | if( group != 0 ) group->Release(); |
| 1288 | } |
| 1289 | |
| 1290 | for (asUINT v = 0; v < scriptData->variables.GetLength(); v++) |
| 1291 | { |
| 1292 | asCTypeInfo* ti = reinterpret_cast<asCTypeInfo*>(scriptData->variables[v]->type.GetTypeInfo()); |
| 1293 | if (ti) // The null handle is also stored, but it doesn't have an object type |
| 1294 | { |
| 1295 | ti->ReleaseInternal(); |
| 1296 | |
| 1297 | asCConfigGroup* group = engine->FindConfigGroupForTypeInfo(ti); |
| 1298 | if (group != 0) group->Release(); |
| 1299 | } |
| 1300 | } |
| 1301 | |
| 1302 | // Go through the byte code and release references to all resources used by the function |
| 1303 | asCArray<asDWORD> &bc = scriptData->byteCode; |
| 1304 | for( asUINT n = 0; n < bc.GetLength(); n += asBCTypeSize[asBCInfo[*(asBYTE*)&bc[n]].type] ) |
| 1305 | { |
| 1306 | switch( *(asBYTE*)&bc[n] ) |
| 1307 | { |
| 1308 | // Object types |
| 1309 | case asBC_OBJTYPE: |
| 1310 | case asBC_FREE: |
| 1311 | case asBC_REFCPY: |
| 1312 | case asBC_RefCpyV: |
| 1313 | { |
| 1314 | asCObjectType *objType = (asCObjectType*)asBC_PTRARG(&bc[n]); |
| 1315 | if( objType ) |
| 1316 | objType->ReleaseInternal(); |
| 1317 | } |
| 1318 | break; |
| 1319 | |
| 1320 | // Object type and function |
| 1321 | case asBC_ALLOC: |
| 1322 | { |
| 1323 | asCObjectType *objType = (asCObjectType*)asBC_PTRARG(&bc[n]); |
nothing calls this directly
no test coverage detected