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

Method FixupClass

NULLC/Executor.cpp:2081–2132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2079}
2080
2081void Executor::FixupClass(char* ptr, const ExternTypeInfo& type)
2082{
2083 const ExternTypeInfo *realType = &type;
2084 if(type.nameHash == ExPriv::objectName)
2085 {
2086 // Get real variable type
2087 realType = &exTypes[*(int*)ptr];
2088 // Switch pointer to target
2089 char **rPtr = (char**)(ptr + 4);
2090 // If it points to stack, fix it and return
2091 if(*rPtr >= ExPriv::oldBase && *rPtr < (ExPriv::oldBase + ExPriv::oldSize))
2092 {
2093 *rPtr = *rPtr - ExPriv::oldBase + ExPriv::newBase;
2094 return;
2095 }
2096 ptr = *rPtr;
2097 // If uninitialized, return
2098 if(!ptr || ptr <= (char*)0x00010000)
2099 return;
2100 // Get base pointer
2101 unsigned int *basePtr = (unsigned int*)NULLC::GetBasePointer(ptr);
2102 markerType *marker = (markerType*)((char*)basePtr - sizeof(markerType));
2103 // If there is no base pointer or memory already marked, exit
2104 if(!basePtr || !(*marker & 1))
2105 return;
2106 // Mark memory as used
2107 *marker &= ~1;
2108 // Fixup target
2109 FixupVariable(*rPtr, *realType);
2110 // Exit
2111 return;
2112 }else if(type.nameHash == ExPriv::autoArrayName){
2113 FixupArray(ptr, type);
2114 // Exit
2115 return;
2116 }
2117 // Get class member type list
2118 unsigned int *memberList = &exLinker->exTypeExtra[realType->memberOffset + realType->memberCount];
2119 //char *str = symbols + type.offsetToName;
2120 //const char *memberName = symbols + type.offsetToName + strlen(str) + 1;
2121 // Check pointer members
2122 for(unsigned int n = 0; n < realType->pointerCount; n++)
2123 {
2124 // Get member type
2125 ExternTypeInfo &subType = exTypes[memberList[n * 2]];
2126 unsigned int pos = memberList[n * 2 + 1];
2127 // Check member
2128 FixupVariable(ptr + pos, subType);
2129 //unsigned int strLength = (unsigned int)strlen(memberName) + 1;
2130 //memberName += strLength;
2131 }
2132}
2133
2134void Executor::FixupFunction(char* ptr)
2135{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected