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

Method Run

NULLC/Executor_LLVM.cpp:189–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189void ExecutorLLVM::Run(unsigned int functionID, const char *arguments)
190{
191 (void)functionID;
192 (void)arguments;
193
194 if(functionID != ~0u)
195 {
196 sprintf(execError, "ERROR: function call unsupported");
197 return;
198 }
199 llvmReturnedType = LLVM_NONE;
200
201 execError[0] = 0;
202
203 printf("LLVM executor\n");
204
205 if(!exLinker->llvmModuleSizes.size())
206 {
207 printf("Code not found\n");
208 assert(0);
209 }
210 LLVM::modules.clear();
211 LLVM::linker = new llvm::Linker("main", "main", LLVM::context);
212
213 std::string error;
214
215 unsigned offset = 0;
216 for(unsigned i = 0; i < exLinker->llvmModuleSizes.size(); i++)
217 {
218 char buf[32];
219 llvm::MemoryBuffer *buffer = llvm::MemoryBuffer::getMemBuffer(&exLinker->llvmModuleCodes[offset], &exLinker->llvmModuleCodes[offset + exLinker->llvmModuleSizes[i] - 1]);
220 llvm::Module *module = llvm::ParseBitcodeFile(buffer, LLVM::context, &error);
221 if(!error.empty())
222 {
223 printf("%s\n", error.c_str());
224 assert(0);
225 }
226
227 llvm::Function *glob = module->getFunction("Global");
228 sprintf(buf, "Global%d", i);
229 glob->setName(buf);
230 if(LLVM::linker->LinkInModule(module, &error))
231 {
232 printf("%s\n", error.c_str());
233 assert(0);
234 }
235 /*if(!i)
236 {
237
238 }else{
239 LLVM::TheExecutionEngine->addModule(module);
240 }*/
241 offset += exLinker->llvmModuleSizes[i];
242 LLVM::modules.push_back(module);
243
244
245 }
246 llvm::Module *module = LLVM::linker->releaseModule();//LLVM::linker->getModule();

Callers

nothing calls this directly

Calls 10

assertFunction · 0.85
c_strMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
createMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected