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

Function OverrideFunction

NULLC/includes/dynamic.cpp:26–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 }
25
26 void OverrideFunction(NULLCRef dest, NULLCRef src)
27 {
28 assert(linker);
29 if(linker->exTypes[dest.typeID].subCat != ExternTypeInfo::CAT_FUNCTION)
30 {
31 nullcThrowError("Destination variable is not a function");
32 return;
33 }
34 if(linker->exTypes[src.typeID].subCat != ExternTypeInfo::CAT_FUNCTION)
35 {
36 nullcThrowError("Source variable is not a function");
37 return;
38 }
39 if(dest.typeID != src.typeID)
40 {
41 nullcThrowError("Cannot convert from '%s' to '%s'", &linker->exSymbols[linker->exTypes[src.typeID].offsetToName], &linker->exSymbols[linker->exTypes[dest.typeID].offsetToName]);
42 return;
43 }
44 ExternFuncInfo &destFunc = linker->exFunctions[((NULLCFuncPtr*)dest.ptr)->id];
45 ExternFuncInfo &srcFunc = linker->exFunctions[((NULLCFuncPtr*)src.ptr)->id];
46 if(nullcGetCurrentExecutor(NULL) == NULLC_X86)
47 RewriteX86(((NULLCFuncPtr*)dest.ptr)->id, ((NULLCFuncPtr*)src.ptr)->id);
48 destFunc.address = srcFunc.address;
49 destFunc.funcPtr = srcFunc.funcPtr;
50 destFunc.codeSize = srcFunc.codeSize;
51 }
52
53 void Override(NULLCRef dest, NULLCArray code)
54 {

Callers

nothing calls this directly

Calls 4

assertFunction · 0.85
nullcGetCurrentExecutorFunction · 0.85
RewriteX86Function · 0.85
nullcThrowErrorFunction · 0.50

Tested by

no test coverage detected