MCPcopy Create free account
hub / github.com/WheretIB/nullc / GetFunctionContext

Function GetFunctionContext

NULLC/Callbacks.cpp:1285–1317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1283}
1284
1285void 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
1320void AddGetAddressNode(const char* pos, InplaceStr varName)

Callers 3

AddGetAddressNodeFunction · 0.85
ConvertFunctionToPointerFunction · 0.85
AddFunctionCallNodeFunction · 0.85

Calls 7

AllocateStringFunction · 0.85
InplaceStrClass · 0.85
AddGetAddressNodeFunction · 0.85
SetAddressTrackingMethod · 0.80
GetStringHashFunction · 0.70
findMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected