diff options
Diffstat (limited to 'src/compile.cpp')
-rw-r--r-- | src/compile.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/compile.cpp b/src/compile.cpp index 8862f73..8c83e15 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -51,7 +51,28 @@ AFn::lift(CEnv& cenv) return; AType* protT = type->at(1)->as<AType*>(); - liftCall(cenv, *protT); + cenv.engine()->liftCall(cenv, this, *protT); +} + +CValue +AFn::compile(CEnv& cenv) +{ + AType* aFnT = cenv.type(this); + /*const Type* fnT = llType(aFnT); + return fnT ? static_cast<Function*>(impls.find(aFnT)) : NULL;*/ + return impls.find(aFnT); + + /*vector<const Type*> types; + types.push_back(PointerType::get(fnT, 0)); + types.push_back(PointerType::get(Type::VoidTy, 0)); + LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine()); + IRBuilder<> builder = engine->builder; + Value* tag = ConstantInt::get(Type::Int8Ty, GC::TAG_FRAME); + StructType* tupT = StructType::get(types, false); + Value* tupSize = ConstantInt::get(Type::Int32Ty, sizeof(void*) * 2); + Value* tup = builder.CreateCall2(engine->alloc, tupSize, tag, "fn"); + Value* tupPtr = builder.CreateBitCast(tup, PointerType::get(tupT, 0)); + return tupPtr;*/ } void @@ -73,7 +94,7 @@ ACall::lift(CEnv& cenv) if (c->prot()->size() > size() - 1) throw Error(loc, (format("too few arguments to function `%1%'") % at(0)->str()).str()); - c->liftCall(cenv, argsT); // Lift called closure + cenv.engine()->liftCall(cenv, c, argsT); // Lift called closure } CValue @@ -124,3 +145,15 @@ ADef::compile(CEnv& cenv) cenv.vals.def(sym(), val); return val; } + +CValue +AIf::compile(CEnv& cenv) +{ + return cenv.engine()->compileIf(cenv, this); +} + +CValue +APrimitive::compile(CEnv& cenv) +{ + return cenv.engine()->compilePrimitive(cenv, this); +} |