| 5261 | } |
| 5262 | |
| 5263 | void CreateRedirectionTables() |
| 5264 | { |
| 5265 | // Search for virtual function tables in imported modules so that we can add functions from new classes |
| 5266 | unsigned continuations = 0; |
| 5267 | for(unsigned i = 0; i < CodeInfo::varInfo.size(); i++) |
| 5268 | { |
| 5269 | // Name must start from $vtbl and must be at least 15 characters |
| 5270 | if(int(CodeInfo::varInfo[i]->name.end - CodeInfo::varInfo[i]->name.begin) < 15 || memcmp(CodeInfo::varInfo[i]->name.begin, "$vtbl", 5) != 0) |
| 5271 | continue; |
| 5272 | CodeInfo::varInfo[i]->next = vtblList; |
| 5273 | vtblList = CodeInfo::varInfo[i]; |
| 5274 | continuations++; |
| 5275 | } |
| 5276 | VariableInfo *curr = vtblList; |
| 5277 | unsigned int num = 0; |
| 5278 | while(curr) |
| 5279 | { |
| 5280 | TypeInfo *funcType = NULL; |
| 5281 | unsigned int hash = GetStringHash(curr->name.begin + 15); // 15 to skip $vtbl0123456789 from name |
| 5282 | |
| 5283 | // If this is continuation of an imported virtual table, find function type from has code in name |
| 5284 | if(continuations) |
| 5285 | { |
| 5286 | unsigned typeHash = parseInteger(curr->name.begin + 5); // 5 to skip $vtbl |
| 5287 | for(unsigned c = 0; !funcType && c < CodeInfo::typeFunctions.size(); c++) |
| 5288 | { |
| 5289 | if(CodeInfo::typeFunctions[c]->GetFullNameHash() == typeHash) |
| 5290 | funcType = CodeInfo::typeFunctions[c]; |
| 5291 | } |
| 5292 | AddVoidNode(); |
| 5293 | continuations--; |
| 5294 | }else{ |
| 5295 | currType = curr->varType; |
| 5296 | CodeInfo::nodeList.push_back(new NodeNumber(4, typeInt)); |
| 5297 | AddFunctionCallNode(CodeInfo::lastKnownStartPos, "__typeCount", 0); |
| 5298 | CodeInfo::nodeList.push_back(new NodeNumber(0, typeInt)); |
| 5299 | CallAllocationFunction(CodeInfo::lastKnownStartPos, "__newA"); |
| 5300 | CodeInfo::nodeList.back()->typeInfo = currType; |
| 5301 | CodeInfo::varInfo.push_back(curr); |
| 5302 | curr->pos = varTop; |
| 5303 | varTop += curr->varType->size; |
| 5304 | |
| 5305 | AddDefineVariableNode(CodeInfo::lastKnownStartPos, curr, true); |
| 5306 | AddPopNode(CodeInfo::lastKnownStartPos); |
| 5307 | |
| 5308 | funcType = (TypeInfo*)curr->prev; |
| 5309 | } |
| 5310 | |
| 5311 | bestFuncList.clear(); |
| 5312 | // Find all functions with called name that are member functions and have target type |
| 5313 | for(unsigned int i = 0; i < CodeInfo::funcInfo.size(); i++) |
| 5314 | { |
| 5315 | FunctionInfo *func = CodeInfo::funcInfo[i]; |
| 5316 | if(func->nameHashOrig == hash && func->parentClass && func->visible && !((func->address & 0x80000000) && (func->address != -1)) && func->funcType == funcType) |
| 5317 | bestFuncList.push_back(func); |
| 5318 | } |
| 5319 | |
| 5320 | for(unsigned int i = 0; i < CodeInfo::typeInfo.size(); i++) |
no test coverage detected