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

Function nullcLoadModuleBySource

NULLC/nullc.cpp:174–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174nullres nullcLoadModuleBySource(const char* module, const char* code)
175{
176 using namespace NULLC;
177 NULLC_CHECK_INITIALIZED(false);
178
179 if(!nullcCompile(code))
180 return false;
181 if(strlen(module) > 512)
182 {
183 nullcLastError = "ERROR: module name is too long";
184 return false;
185 }
186
187 char path[1024];
188 strcpy(path, module);
189 char *pos = path;
190 while(*pos)
191 if(*pos++ == '.')
192 pos[-1] = '/';
193 strcat(path, ".nc");
194
195 if(BinaryCache::GetBytecode(path))
196 {
197 nullcLastError = "ERROR: module already loaded";
198 return false;
199 }
200
201 char *bytecode = NULL;
202 nullcGetBytecode(&bytecode);
203 BinaryCache::PutBytecode(path, bytecode);
204 return 1;
205}
206
207nullres nullcLoadModuleByBinary(const char* module, const char* binary)
208{

Callers 5

BuildModuleFunction · 0.85
WinMainFunction · 0.85
RunInterfaceTestsFunction · 0.85
SpeedTestTextFunction · 0.85

Calls 2

nullcCompileFunction · 0.85
nullcGetBytecodeFunction · 0.85

Tested by 2

RunInterfaceTestsFunction · 0.68
SpeedTestTextFunction · 0.68