aboutsummaryrefslogtreecommitdiffstats
path: root/src/llvm.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-08 19:07:09 +0000
committerDavid Robillard <d@drobilla.net>2010-12-08 19:07:09 +0000
commitd02fe43f0f6e50f8f22321aa0080283ee2ecc9fc (patch)
tree2a2007137d19221a541e97764dc3adef054f6581 /src/llvm.cpp
parent583a2d9d2397ff174b16d7df377f16c1df6fe875 (diff)
downloadresp-d02fe43f0f6e50f8f22321aa0080283ee2ecc9fc.tar.gz
resp-d02fe43f0f6e50f8f22321aa0080283ee2ecc9fc.tar.bz2
resp-d02fe43f0f6e50f8f22321aa0080283ee2ecc9fc.zip
Clean up function compilation stuff.
Add some utilities to for using named types. git-svn-id: http://svn.drobilla.net/resp/resp@313 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r--src/llvm.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp
index 0dfbc69..32aedf7 100644
--- a/src/llvm.cpp
+++ b/src/llvm.cpp
@@ -124,12 +124,15 @@ struct LLVMEngine : public Engine {
}
return PointerType::get(StructType::get(context, ctypes, false), 0);
+ } else if (t->kind == AType::NAME) {
+ assert(false);
}
+ assert(false);
return PointerType::get(Type::getInt8Ty(context), NULL);
}
- CFunc startFunction(CEnv& cenv,
- const std::string& name, const ATuple* args, const AType* type)
+ CFunc startFunction(
+ CEnv& cenv, const std::string& name, const ATuple* args, const AType* type)
{
const AType* argsT = type->prot()->as_type();
const AType* retT = type->list_last()->as_type();
@@ -166,7 +169,7 @@ struct LLVMEngine : public Engine {
return f;
}
- void pushFunctionArgs(CEnv& cenv, const ATuple* fn, const AType* type, CFunc f);
+ void pushFunctionArgs(CEnv& cenv, const ATuple* prot, const AType* type, CFunc f);
void appendBlock(LLVMEngine* engine, Function* function, BasicBlock* block) {
function->getBasicBlockList().push_back(block);
@@ -349,22 +352,21 @@ LLVMEngine::compileString(CEnv& cenv, const char* str)
}
void
-LLVMEngine::pushFunctionArgs(CEnv& cenv, const ATuple* fn, const AType* type, CFunc f)
+LLVMEngine::pushFunctionArgs(CEnv& cenv, const ATuple* prot, const AType* type, CFunc cfunc)
{
cenv.push();
const AType* argsT = type->prot()->as_type();
-
+ Function* f = llFunc(cfunc);
+
// Bind argument values in CEnv
- vector<Value*> args;
- ATuple::const_iterator p = fn->prot()->begin();
+ ATuple::const_iterator p = prot->begin();
ATuple::const_iterator pT = argsT->begin();
- assert(fn->prot()->size() == argsT->size());
- assert(fn->prot()->size() == f->num_args());
- for (Function::arg_iterator a = llFunc(f)->arg_begin(); a != llFunc(f)->arg_end(); ++a, ++p, ++pT) {
- const AType* t = (*pT)->as_type();
- const Type* lt = llType(t);
- THROW_IF(!lt, fn->loc, "untyped parameter\n");
+ assert(prot->size() == argsT->size());
+ assert(prot->size() == f->num_args());
+ for (Function::arg_iterator a = f->arg_begin(); a != f->arg_end(); ++a, ++p, ++pT) {
+ const AType* t = cenv.resolveType((*pT)->as_type());
+ THROW_IF(!llType(t), (*p)->loc, "untyped parameter\n");
cenv.def((*p)->as_symbol(), *p, t, &*a);
}
}