diff options
author | David Robillard <d@drobilla.net> | 2011-05-15 21:19:37 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-05-15 21:19:37 +0000 |
commit | 4b70c05fed4ece152eedffc33ed53cb28b74df39 (patch) | |
tree | e97c15f48a7b9ebd7e7f2fecedfdd844a8be0210 | |
parent | 8cbb1c710d6c8877dfc2871dc3f068b52598a884 (diff) | |
download | resp-4b70c05fed4ece152eedffc33ed53cb28b74df39.tar.gz resp-4b70c05fed4ece152eedffc33ed53cb28b74df39.tar.bz2 resp-4b70c05fed4ece152eedffc33ed53cb28b74df39.zip |
Remove cast form (unnecessary since compile stage casts paramters as needed anyway).
git-svn-id: http://svn.drobilla.net/resp/trunk@428 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r-- | src/compile.cpp | 15 | ||||
-rw-r--r-- | src/flatten.cpp | 3 | ||||
-rw-r--r-- | src/lift.cpp | 2 | ||||
-rw-r--r-- | src/simplify.cpp | 5 |
4 files changed, 8 insertions, 17 deletions
diff --git a/src/compile.cpp b/src/compile.cpp index f84d789..244fcc6 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -140,12 +140,11 @@ compile_call(CEnv& cenv, const ATuple* call) throw() CFunc f = resp_compile(cenv, call->fst()); vector<CVal> args; - ATuple::const_iterator t = protT->iter_at(0); - for (ATuple::const_iterator e = call->iter_at(1); e != call->end(); ++e, ++t) { - CVal arg = resp_compile(cenv, *e); - if ((*e)->to_symbol() && (cenv.type(*e) != cenv.type(*t))) { - - args.push_back(cenv.engine()->compileCast(cenv, arg, *t)); + ATuple::const_iterator p = protT->iter_at(0); + for (ATuple::const_iterator a = call->iter_at(1); a != call->end(); ++a, ++p) { + CVal arg = resp_compile(cenv, *a); + if (cenv.type(*a) != cenv.resolveType(*p)) { + args.push_back(cenv.engine()->compileCast(cenv, arg, *p)); } else { args.push_back(arg); } @@ -207,10 +206,6 @@ resp_compile(CEnv& cenv, const AST* ast) throw() const std::string form = sym ? sym->sym() : ""; if (is_primitive(cenv.penv, call)) return cenv.engine()->compilePrimitive(cenv, ast->as_tuple()); - else if (form == "cast") - return cenv.engine()->compileCast(cenv, - resp_compile(cenv, call->frst()), - cenv.type(call)); else if (form == "cons" || isupper(form[0])) return compile_cons(cenv, call); else if (form == ".") diff --git a/src/flatten.cpp b/src/flatten.cpp index 613403b..dfbd7a3 100644 --- a/src/flatten.cpp +++ b/src/flatten.cpp @@ -172,8 +172,7 @@ resp_flatten(CEnv& cenv, Code& code, const AST* ast) throw() const ASymbol* const sym = call->fst()->to_symbol(); const std::string form = sym ? sym->sym() : ""; assert(form != "fn"); - if (form == "cast" - || form == "quote") + if (form == "quote") return ast; else if (form == "def") return flatten_def(cenv, code, call); diff --git a/src/lift.cpp b/src/lift.cpp index 518fc4f..1d4e19c 100644 --- a/src/lift.cpp +++ b/src/lift.cpp @@ -285,7 +285,7 @@ resp_lift(CEnv& cenv, Code& code, const AST* ast) throw() return lift_fn(cenv, code, call); else if (form == "if") return lift_args(cenv, code, call); - else if (form == "quote" || form == "cast") + else if (form == "quote") return call; else return lift_call(cenv, code, call); diff --git a/src/simplify.cpp b/src/simplify.cpp index d6188ad..ea83cff 100644 --- a/src/simplify.cpp +++ b/src/simplify.cpp @@ -113,10 +113,7 @@ simplify_match(CEnv& cenv, const ATuple* match) throw() assert(fnT.head->list_ref(1)); cenv.setType(fn, fnT); - const ATuple* cast = tup(Cursor(), cenv.penv.sym("cast"), obj, 0); - cenv.setType(cast, texp->rst()); - - List call(Cursor(), fn, cast, 0); + List call(Cursor(), fn, obj, 0); cenv.setTypeSameAs(call, match); copyIf.push_back(call); } |