27 Jan '14, 10pm

This is golddd @evanphx thanks!

Function* create(Module** out) { std::string error; Module* jit; // Load in the bitcode file containing the functions for each // bytecode operation. if(MemoryBuffer* buffer = MemoryBuffer::getFile("ops.o", &error)) { jit = ParseBitcodeFile(buffer, &error); delete buffer; } // Pull out references to them. Function* set = jit->getFunction(std::string("set")); Function* add = jit->getFunction(std::string("add")); Function* show = jit->getFunction(std::string("show")); // Now, begin building our new function, which calls the // above functions. Function* body = cast<Function>(jit->getOrInsertFunction("body", Type::VoidTy, PointerType::getUnqual(Type::Int32Ty), PointerType::getUnqual(Type::Int32Ty), (Type*)0)); // Our function will be passed the ops pointer and the // registers pointer, just like before. Function::arg_iterator args = body->arg_begin(); Value* ops = args++; ops...

Full article: http://blog.fallingsnow.net/2008/05/23/simple-vm-jit-with...

Tweets