diff options
author | David Robillard <d@drobilla.net> | 2012-12-25 08:35:43 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-12-25 08:35:43 +0000 |
commit | 77d27b3495bfa98c5e13707903e4f885e8521ab6 (patch) | |
tree | b2cadb927fd0ab8732001fc77a580f1dffcd0744 /src/simplify.cpp | |
parent | 12314c754187ae246bc38aceb827bf51d1669d73 (diff) | |
download | resp-77d27b3495bfa98c5e13707903e4f885e8521ab6.tar.gz resp-77d27b3495bfa98c5e13707903e4f885e8521ab6.tar.bz2 resp-77d27b3495bfa98c5e13707903e4f885e8521ab6.zip |
Support multiple ellipses in macros.
Support lambda expressions with empty argument lists.
git-svn-id: http://svn.drobilla.net/resp/trunk@445 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/simplify.cpp')
-rw-r--r-- | src/simplify.cpp | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/src/simplify.cpp b/src/simplify.cpp index f1b1bec..34c1ef0 100644 --- a/src/simplify.cpp +++ b/src/simplify.cpp @@ -139,39 +139,6 @@ simplify_list(CEnv& cenv, Code& code, const ATuple* call) throw() return copy; } -static const AST* -simplify_let(CEnv& cenv, Code& code, const ATuple* call) throw() -{ - const ATuple* vars = call->list_ref(1)->to_tuple(); - - List fn(Cursor(), cenv.penv.sym("lambda"), NULL); - - List fnProt; - List fnArgs; - List fnProtT; - for (ATuple::const_iterator i = vars->begin(); i != vars->end();) { - const ASymbol* sym = (*i++)->to_symbol(); - const AST* val = (*i++); - fnProt.push_back(sym); - fnArgs.push_back(resp_simplify(cenv, code, val)); - fnProtT.push_back(cenv.type(val)); - } - - fn.push_back(fnProt.head); - fn.push_back(resp_simplify(cenv, code, call->list_ref(2))); - - List fnT; - fnT.push_back(cenv.tenv.Fn); - fnT.push_back(fnProtT); - fnT.push_back(cenv.type(call->list_ref(2))); - cenv.setType(fn, fnT); - - ATuple* copy = new ATuple(fn, fnArgs, call->loc); - cenv.setTypeSameAs(copy, call); - - return copy; -} - static inline const AST* quote(CEnv& cenv, const AST* ast); @@ -219,18 +186,16 @@ const AST* resp_simplify(CEnv& cenv, Code& code, const AST* ast) throw() { const ATuple* const list = ast->to_tuple(); - if (!list) + if (!list || !list->fst()) return ast; - const ASymbol* const sym = list->fst()->to_symbol(); + const ASymbol* const sym = list->fst() ? list->fst()->to_symbol() : 0; const std::string form = sym ? sym->sym() : ""; if (form == "match") return simplify_match(cenv, code, list); else if (form == "if") return simplify_if(cenv, code, list); - else if (form == "let") - return simplify_let(cenv, code, list); else if (form == "quote") return simplify_quote(cenv, code, list); else |