#include <sstream>
#include <string>
#include <vector>
+
using namespace llvm;
+using namespace llvm::orc;
//===----------------------------------------------------------------------===//
// Lexer
LLVMContext& getLLVMContext() const { return Context; }
void addPrototypeAST(std::unique_ptr<PrototypeAST> P);
PrototypeAST* getPrototypeAST(const std::string &Name);
- std::map<std::string, std::unique_ptr<FunctionAST>> FunctionDefs;
private:
typedef std::map<std::string, std::unique_ptr<PrototypeAST>> PrototypeMap;
LLVMContext &Context;
auto H = irGenStub(std::move(DefI->second));
// Remove the map entry now that we're done with it.
- Session.FunctionDefs.erase(DefI);
+ FunctionDefs.erase(DefI);
// Return the address of the stub.
return findMangledSymbolIn(H, Name).getAddress();
}
// This method will take the AST for a function definition and IR-gen a stub
- // for that function that will, on first call, IR-gen the action body of the
+ // for that function that will, on first call, IR-gen the actual body of the
// function.
ModuleHandleT irGenStub(std::unique_ptr<FunctionAST> FnAST) {
// Step 1) IRGen a prototype for the stub. This will have the same type as
//
// The update action will update FunctionBodyPointer to point at the newly
// compiled function.
- CallbackInfo.setCompileAction(
- [this, Fn = std::shared_ptr<FunctionAST>(std::move(FnAST))](){
- auto H = addModule(IRGen(Session, *Fn));
- return findSymbolIn(H, Fn->Proto->Name).getAddress();
- });
+ std::shared_ptr<FunctionAST> Fn = std::move(FnAST);
+ CallbackInfo.setCompileAction([this, Fn]() {
+ auto H = addModule(IRGen(Session, *Fn));
+ return findSymbolIn(H, Fn->Proto->Name).getAddress();
+ });
CallbackInfo.setUpdateAction(
CompileCallbacks.getLocalFPUpdater(H, Mangle(BodyPtrName)));