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/compile.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/compile.cpp')
-rw-r--r-- | src/compile.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/compile.cpp b/src/compile.cpp index 554fab6..48c2b0a 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -151,6 +151,28 @@ compile_if(CEnv& cenv, const ATuple* aif) throw() return cenv.engine()->compileIfEnd(cenv, state, elseV, cenv.type(aif)); } +static CVal +compile_match(CEnv& cenv, const ATuple* match) throw() +{ + IfState state = cenv.engine()->compileIfStart(cenv); + CVal matchee = resp_compile(cenv, match->list_ref(1)); + CVal rtti = cenv.engine()->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(); + + CVal condV = cenv.engine()->compileIsA(cenv, rtti, sym); + + cenv.engine()->compileIfBranch(cenv, state, condV, body); + } + + const AType* type = cenv.type(match); + return cenv.engine()->compileIfEnd(cenv, state, NULL, type); +} + CVal resp_compile(CEnv& cenv, const AST* ast) throw() { @@ -185,7 +207,7 @@ resp_compile(CEnv& cenv, const AST* ast) throw() else if (form == ".") return compile_dot(cenv, call); else if (form == "match") - return cenv.engine()->compileMatch(cenv, call); + return compile_match(cenv, call); else if (form == "def-type") return NULL; else |