void asCBuilder::GetFunctionDescriptions(const char *name, asCArray<int> &funcs) { asUINT n; // TODO: Improve linear search for( n = 0; n < module->scriptFunctions.GetLength(); n++ ) { if( module->scriptFunctions[n]->name == name && module->scriptFunctions[n]->objectType == 0 ) funcs.PushLast(module->scriptFunctions[n]->id); } // TODO: Improve linear search for( n = 0; n < module->importedFunctions.GetLength(); n++ ) { if( module->importedFunctions[n]->name == name ) funcs.PushLast(module->importedFunctions[n]->id); } // TODO: Improve linear search for( n = 0; n < engine->scriptFunctions.GetLength(); n++ ) { if( engine->scriptFunctions[n] && engine->scriptFunctions[n]->funcType == asFUNC_SYSTEM && engine->scriptFunctions[n]->objectType == 0 && engine->scriptFunctions[n]->name == name ) { // Find the config group for the global function asCConfigGroup *group = engine->FindConfigGroupForFunction(engine->scriptFunctions[n]->id); if( !group || group->HasModuleAccess(module->name.AddressOf()) ) funcs.PushLast(engine->scriptFunctions[n]->id); } } }
bool asCModule::CanDeleteAllReferences(asCArray<asCModule*> &modules) { if( !isDiscarded ) return false; if( contextCount ) return false; modules.PushLast(this); // Check all bound functions for referenced modules for( asUINT n = 0; n < bindInformations.GetLength(); n++ ) { int funcID = bindInformations[n].importedFunction; asCModule *module = engine->GetModule(funcID); // If the module is already in the list don't check it again bool inList = false; for( asUINT m = 0; m < modules.GetLength(); m++ ) { if( modules[m] == module ) { inList = true; break; } } if( !inList ) { bool ret = module->CanDeleteAllReferences(modules); if( ret == false ) return false; } } // If no module has external references then all can be deleted return true; }
void asCScriptStruct::AddUnmarkedReferences(asCArray<asCGCObject*> &unmarked) { for( asUINT n = 0; n < gc.objType->properties.GetLength(); n++ ) { asCProperty *prop = gc.objType->properties[n]; if( prop->type.IsObject() && (prop->type.GetObjectType()->flags & asOBJ_POTENTIAL_CIRCLE) ) { asCGCObject *ptr = *(asCGCObject**)(((char*)this) + prop->byteOffset); if( ptr && ptr->gc.gcCount == 0 ) unmarked.PushLast(ptr); } } }
void asCBuilder::GetObjectMethodDescriptions(const char *name, asCObjectType *objectType, asCArray<int> &methods, bool objIsConst) { // TODO: Improve linear search if( objIsConst ) { // Only add const methods to the list for( asUINT n = 0; n < objectType->methods.GetLength(); n++ ) { if( engine->scriptFunctions[objectType->methods[n]]->name == name && engine->scriptFunctions[objectType->methods[n]]->isReadOnly ) methods.PushLast(engine->scriptFunctions[objectType->methods[n]]->id); } } else { // TODO: Prefer non-const over const for( asUINT n = 0; n < objectType->methods.GetLength(); n++ ) { if( engine->scriptFunctions[objectType->methods[n]]->name == name ) methods.PushLast(engine->scriptFunctions[objectType->methods[n]]->id); } } }
// internal bool asCModule::AreTypesEqual(const asCDataType &a, const asCDataType &b, asCArray<sObjectTypePair> &equals) { if( !a.IsEqualExceptInterfaceType(b) ) return false; asCObjectType *ai = a.GetObjectType(); asCObjectType *bi = b.GetObjectType(); if( ai && ai->IsInterface() ) { // If the interface is in the equals list, then the pair must match the pair in the list bool found = false; unsigned int e; for( e = 0; e < equals.GetLength(); e++ ) { if( equals[e].a == ai ) { found = true; break; } } if( found ) { // Do the pairs match? if( equals[e].b != bi ) return false; } else { // Assume they are equal from now on sObjectTypePair pair = {ai, bi}; equals.PushLast(pair); } } return true; }