| 1283 | } |
| 1284 | |
| 1285 | void GetFunctionContext(const char* pos, FunctionInfo *fInfo, bool handleThisCall) |
| 1286 | { |
| 1287 | if(fInfo->type == FunctionInfo::LOCAL || fInfo->type == FunctionInfo::COROUTINE) |
| 1288 | { |
| 1289 | VariableInfo **info = NULL; |
| 1290 | InplaceStr context; |
| 1291 | // If function is already implemented, we can take context variable information from function information |
| 1292 | if(fInfo->funcContext) |
| 1293 | { |
| 1294 | info = &fInfo->funcContext; |
| 1295 | context = (*info)->name; |
| 1296 | }else{ |
| 1297 | char *contextName = AllocateString(fInfo->nameLength + 24); |
| 1298 | int length = sprintf(contextName, "$%s_%d_ext", fInfo->name, fInfo->indexInArr); |
| 1299 | unsigned int contextHash = GetStringHash(contextName); |
| 1300 | info = varMap.find(contextHash); |
| 1301 | context = InplaceStr(contextName, length); |
| 1302 | } |
| 1303 | if(!info) |
| 1304 | { |
| 1305 | CodeInfo::nodeList.push_back(new NodeNumber(0, CodeInfo::GetReferenceType(typeInt))); |
| 1306 | }else{ |
| 1307 | AddGetAddressNode(pos, context); |
| 1308 | // This could be a forward-declared context, so make sure address will be correct if it changes |
| 1309 | if(CodeInfo::nodeList.back()->nodeType == typeNodeGetAddress) |
| 1310 | ((NodeGetAddress*)CodeInfo::nodeList.back())->SetAddressTracking(); |
| 1311 | CodeInfo::nodeList.push_back(new NodeDereference()); |
| 1312 | } |
| 1313 | }else if(fInfo->type == FunctionInfo::THISCALL && handleThisCall){ |
| 1314 | AddGetAddressNode(pos, InplaceStr("this", 4)); |
| 1315 | CodeInfo::nodeList.push_back(new NodeDereference()); |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | // Function that retrieves variable address |
| 1320 | void AddGetAddressNode(const char* pos, InplaceStr varName) |
no test coverage detected