Use lambdas in stdlib. (#140)

This commit is contained in:
Nikolay Igotti
2016-12-14 16:46:39 +03:00
committed by GitHub
parent 35668cc7e1
commit 08bdcc963f
18 changed files with 1145 additions and 49 deletions
@@ -51,12 +51,14 @@ internal fun emitLLVM(context: Context) {
LLVMWriteBitcodeToFile(llvmModule, outFile)
}
internal fun verifyModule(llvmModule: LLVMModuleRef) {
internal fun verifyModule(llvmModule: LLVMModuleRef, current: String = "") {
memScoped {
val errorRef = allocPointerTo<CInt8Var>()
// TODO: use LLVMDisposeMessage() on errorRef, once possible in interop.
if (LLVMVerifyModule(
llvmModule, LLVMVerifierFailureAction.LLVMPrintMessageAction, errorRef.ptr) == 1) {
if (current.length > 0)
println("Error in ${current}")
LLVMDumpModule(llvmModule)
throw Error("Invalid module");
}
@@ -516,7 +518,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
codegen.epilogue(declaration)
verifyModule(context.llvmModule!!)
verifyModule(context.llvmModule!!, ir2string(declaration))
}
//-------------------------------------------------------------------------//