diff options
author | David Robillard <d@drobilla.net> | 2010-12-08 22:39:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-08 22:39:45 +0000 |
commit | 9505e74e3a46eb0b5b1d2e0cce4d9a5092ebedc9 (patch) | |
tree | de7494695370b750b6d8a222acba30ff66f24f55 /src/llvm.cpp | |
parent | c3601526574d9f04779cea3a84c8b423e6b3fb26 (diff) | |
download | resp-9505e74e3a46eb0b5b1d2e0cce4d9a5092ebedc9.tar.gz resp-9505e74e3a46eb0b5b1d2e0cce4d9a5092ebedc9.tar.bz2 resp-9505e74e3a46eb0b5b1d2e0cce4d9a5092ebedc9.zip |
Remove Engine::compileMatch.
git-svn-id: http://svn.drobilla.net/resp/resp@318 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/llvm.cpp')
-rw-r--r-- | src/llvm.cpp | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/llvm.cpp b/src/llvm.cpp index 6975861..eeb584c 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -206,7 +206,7 @@ struct LLVMEngine : public Engine { CVal compileString(CEnv& cenv, const char* str); CVal compilePrimitive(CEnv& cenv, const ATuple* prim); CVal compileIf(CEnv& cenv, const ATuple* aif); - CVal compileMatch(CEnv& cenv, const ATuple* match); + CVal compileIsA(CEnv& cenv, CVal rtti, const ASymbol* tag); CVal compileGlobal(CEnv& cenv, const AType* type, const string& sym, CVal val); CVal compileGlobalGet(CEnv& cenv, const string& sym, CVal val); @@ -405,7 +405,10 @@ LLVMEngine::compileIfEnd(CEnv& cenv, IfState s, CVal elseV, const AType* type) { LLVMIfState* state = (LLVMIfState*)s; LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine()); - + + if (!elseV) + elseV = Constant::getNullValue(llType(type)); + // Emit end of final else block engine->builder.CreateBr(state->mergeBB); state->branches.push_back(make_pair(llVal(elseV), engine->builder.GetInsertBlock())); @@ -420,29 +423,13 @@ LLVMEngine::compileIfEnd(CEnv& cenv, IfState s, CVal elseV, const AType* type) } CVal -LLVMEngine::compileMatch(CEnv& cenv, const ATuple* match) +LLVMEngine::compileIsA(CEnv& cenv, CVal rtti, const ASymbol* tag) { - LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine()); - IfState state = compileIfStart(cenv); - CVal matchee = resp_compile(cenv, match->list_ref(1)); - Value* rtti = llVal(compileDot(cenv, matchee, 0)); - - size_t idx = 1; - for (ATuple::const_iterator i = match->iter_at(2); i != match->end(); ++idx) { - const AST* pat = *i++; - const AST* body = *i++; - const ASymbol* sym = pat->as_tuple()->head()->as_symbol(); - const AType* patT = new AType(sym, 0, Cursor()); - - Value* typeV = llVal(resp_compile(cenv, patT)); - Value* condV = engine->builder.CreateICmp(CmpInst::ICMP_EQ, rtti, typeV); - - compileIfBranch(cenv, state, condV, body); - } + LLVMEngine* engine = reinterpret_cast<LLVMEngine*>(cenv.engine()); + const AType* patT = new AType(tag, 0, Cursor()); + Value* typeV = llVal(resp_compile(cenv, patT)); - const AType* type = cenv.type(match); - CVal elseV = Constant::getNullValue(llType(type)); - return compileIfEnd(cenv, state, elseV, type); + return engine->builder.CreateICmp(CmpInst::ICMP_EQ, llVal(rtti), typeV); } CVal |