From d4b45062903586e86daed7d1f319df6b2133644b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 15 Oct 2009 16:15:23 +0000 Subject: Better error reporting for failed function compiles (print uncompilable type). git-svn-id: http://svn.drobilla.net/resp/tuplr@224 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/c.cpp | 10 ++++++---- src/llvm.cpp | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/c.cpp b/src/c.cpp index bf98638..1237979 100644 --- a/src/c.cpp +++ b/src/c.cpp @@ -95,7 +95,8 @@ struct CEngine : public Engine { cprot.push_back(llType(at)); } - THROW_IF(!llType(retT), Cursor(), "return has non-concrete type"); + THROW_IF(!llType(retT), Cursor(), + (format("return has non-concrete type `%1%'") % retT->str()).str()); Function* f = new Function(); f->returnType = *llType(retT); @@ -167,10 +168,11 @@ CEngine::compileLiteral(CEnv& cenv, AST* lit) CFunc CEngine::compileFunction(CEnv& cenv, AFn* fn, const AType& argsT) { - TEnv::GenericTypes::const_iterator gt = cenv.tenv.genericTypes.find(fn); - assert(gt != cenv.tenv.genericTypes.end()); + //TEnv::GenericTypes::const_iterator gt = cenv.tenv.genericTypes.find(fn); + //assert(gt != cenv.tenv.genericTypes.end()); CEngine* engine = reinterpret_cast(cenv.engine()); - AType* genericType = new AType(*gt->second); + //AType* genericType = new AType(*gt->second); + AType* genericType = cenv.type(fn); AType* thisType = genericType; Subst argsSubst; diff --git a/src/llvm.cpp b/src/llvm.cpp index 1477917..d022413 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -114,7 +114,9 @@ struct LLVMEngine : public Engine { cprot.push_back(llType(at)); } - THROW_IF(!llType(retT), Cursor(), "return has non-concrete type"); + THROW_IF(!llType(retT), Cursor(), + (format("return has non-concrete type `%1%'") % retT->str()).str()); + FunctionType* fT = FunctionType::get(llType(retT), cprot, false); Function* f = Function::Create(fT, linkage, name, module); -- cgit v1.2.1