diff options
author | David Robillard <d@drobilla.net> | 2010-12-02 06:16:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-02 06:16:29 +0000 |
commit | 563a807be78bfe12e5bfbb9ff0d6da44242696c4 (patch) | |
tree | 13cf7ce3b90d072d6e7106c7d2eb4da33209acb0 /src/llvm.cpp | |
parent | 32ac40a9ef62d2109563e36fb7cd478426c3489f (diff) | |
download | resp-563a807be78bfe12e5bfbb9ff0d6da44242696c4.tar.gz resp-563a807be78bfe12e5bfbb9ff0d6da44242696c4.tar.bz2 resp-563a807be78bfe12e5bfbb9ff0d6da44242696c4.zip |
Represent code as list structure (i.e. traditional LISP lists built from pairs), rather than tuple structure.
Remove unused/crufty depoly stage.
Remove cps from AST interface (but keep cps.cpp code around for later).
Improved command line interface for compilation stages (options -T -L -S).
git-svn-id: http://svn.drobilla.net/resp/resp@277 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r-- | src/llvm.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp index 24846cc..3e55b98 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -116,7 +116,7 @@ struct LLVMEngine : public Engine { } else if (t->kind == AType::EXPR && isupper(t->head()->str()[0])) { vector<const Type*> ctypes; ctypes.push_back(PointerType::get(Type::getInt8Ty(context), NULL)); // RTTI - for (AType::const_iterator i = t->begin() + 1; i != t->end(); ++i) { + for (AType::const_iterator i = t->iter_at(1); i != t->end(); ++i) { const Type* lt = llType((*i)->to<const AType*>()); if (!lt) return NULL; @@ -132,13 +132,13 @@ struct LLVMEngine : public Engine { const std::string& name, const ATuple* args, const AType* type) { const AType* argsT = type->prot()->as<const AType*>(); - const AType* retT = type->last()->as<const AType*>(); + const AType* retT = type->list_last()->as<const AType*>(); Function::LinkageTypes linkage = Function::ExternalLinkage; vector<const Type*> cprot; FOREACHP(ATuple::const_iterator, i, argsT) { - AType* at = (*i)->as<AType*>(); + const AType* at = (*i)->as<const AType*>(); THROW_IF(!llType(at), Cursor(), string("non-concrete parameter :: ") + at->str()) cprot.push_back(llType(at)); @@ -278,8 +278,8 @@ LLVMEngine::compileTup(CEnv& cenv, const AType* type, CVal rtti, const vector<CV // Find size of memory required size_t s = engine->getTargetData()->getTypeSizeInBits(PointerType::get(Type::getInt8Ty(context), NULL)); assert(type->begin() != type->end()); - for (AType::const_iterator i = type->begin() + 1; i != type->end(); ++i) - s += engine->getTargetData()->getTypeSizeInBits(llType((*i)->as<AType*>())); + for (AType::const_iterator i = type->iter_at(1); i != type->end(); ++i) + s += engine->getTargetData()->getTypeSizeInBits(llType((*i)->as<const AType*>())); // Allocate struct Value* structSize = ConstantInt::get(Type::getInt32Ty(context), bitsToBytes(s)); @@ -346,7 +346,7 @@ LLVMEngine::pushFunctionArgs(CEnv& cenv, const AFn* fn, const AType* type, CFunc const AType* t = (*pT)->as<const AType*>(); const Type* lt = llType(t); THROW_IF(!lt, fn->loc, "untyped parameter\n"); - cenv.def((*p)->as<ASymbol*>(), *p, t, &*a); + cenv.def((*p)->as<const ASymbol*>(), *p, t, &*a); } } @@ -360,7 +360,7 @@ LLVMEngine::compileIf(CEnv& cenv, const AIf* aif) BasicBlock* nextBB = NULL; Branches branches; size_t idx = 1; - for (AIf::const_iterator i = aif->begin() + 1; ; ++i, idx += 2) { + for (AIf::const_iterator i = aif->iter_at(1); ; ++i, idx += 2) { AIf::const_iterator next = i; if (++next == aif->end()) break; @@ -386,7 +386,7 @@ LLVMEngine::compileIf(CEnv& cenv, const AIf* aif) } // Emit final else block - Value* elseV = llVal(aif->last()->compile(cenv)); + Value* elseV = llVal(aif->list_last()->compile(cenv)); engine->builder.CreateBr(mergeBB); branches.push_back(make_pair(elseV, engine->builder.GetInsertBlock())); @@ -405,7 +405,7 @@ CVal LLVMEngine::compileMatch(CEnv& cenv, const AMatch* match) { typedef vector< pair<Value*, BasicBlock*> > Branches; - Value* matchee = llVal((*(match->begin() + 1))->compile(cenv)); + Value* matchee = llVal(match->list_ref(1)->compile(cenv)); Value* rttiPtr = builder.CreateStructGEP(matchee, 0, "matchRTTIPtr"); Value* rtti = builder.CreateLoad(rttiPtr, 0, "matchRTTI"); @@ -416,7 +416,7 @@ LLVMEngine::compileMatch(CEnv& cenv, const AMatch* match) Branches branches; size_t idx = 1; - for (AMatch::const_iterator i = match->begin() + 2; i != match->end(); ++idx) { + for (AMatch::const_iterator i = match->iter_at(2); i != match->end(); ++idx) { const AST* pat = *i++; const AST* body = *i++; const ASymbol* sym = pat->to<const ATuple*>()->head()->as<const ASymbol*>(); |