From 8ee352054cff3512c8e6dc3fd4738ee24ad267af Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 4 Dec 2010 23:01:58 +0000 Subject: More const-correctness. git-svn-id: http://svn.drobilla.net/resp/resp@295 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/lift.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/lift.cpp') diff --git a/src/lift.cpp b/src/lift.cpp index e98ddc6..5b3f871 100644 --- a/src/lift.cpp +++ b/src/lift.cpp @@ -50,10 +50,10 @@ lift_symbol(CEnv& cenv, Code& code, const ASymbol* sym) throw() } static AST* -lift_fn(CEnv& cenv, Code& code, ATuple* fn) throw() +lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw() { List impl; - impl.push_back(fn->head()); + impl.push_back(const_cast(fn->head())); const string fnName = cenv.name(fn); const string nameBase = cenv.penv.gensymstr(((fnName != "") ? fnName : "fn").c_str()); @@ -61,7 +61,7 @@ lift_fn(CEnv& cenv, Code& code, ATuple* fn) throw() cenv.setName(impl, implNameStr); cenv.liftStack.push(CEnv::FreeVars(fn, implNameStr)); - + // Create a new stub environment frame for parameters cenv.push(); const AType* type = cenv.type(fn); @@ -136,7 +136,7 @@ lift_fn(CEnv& cenv, Code& code, ATuple* fn) throw() } static AST* -lift_call(CEnv& cenv, Code& code, ATuple* call) throw() +lift_call(CEnv& cenv, Code& code, const ATuple* call) throw() { List copy; @@ -185,7 +185,7 @@ lift_call(CEnv& cenv, Code& code, ATuple* call) throw() } static AST* -lift_def(CEnv& cenv, Code& code, ATuple* def) throw() +lift_def(CEnv& cenv, Code& code, const ATuple* def) throw() { // Define stub first for recursion const ASymbol* const sym = def->list_ref(1)->as_symbol(); @@ -196,12 +196,13 @@ lift_def(CEnv& cenv, Code& code, ATuple* def) throw() assert(def->list_ref(1)->to_symbol()); List copy; - copy.push_back(def->head()); + copy.push_back(const_cast(def->head())); copy.push_back(const_cast(resp_lift(cenv, code, def->list_ref(1)))); for (ATuple::const_iterator t = def->iter_at(2); t != def->end(); ++t) copy.push_back(const_cast(resp_lift(cenv, code, *t))); - cenv.setTypeSameAs(copy, def); + cenv.setTypeSameAs(const_cast(static_cast(copy.head)), + const_cast(static_cast(def))); if (copy.head->list_ref(1) == copy.head->list_ref(2)) return NULL; // Definition created by lift_fn when body was lifted @@ -214,16 +215,18 @@ lift_def(CEnv& cenv, Code& code, ATuple* def) throw() } static AST* -lift_builtin_call(CEnv& cenv, Code& code, ATuple* call) throw() +lift_builtin_call(CEnv& cenv, Code& code, const ATuple* call) throw() { - List copy; - copy.push_back(call->head()); + List copy; + copy.push_back(const_cast(call->head())); // Lift all arguments for (ATuple::const_iterator i = call->iter_at(1); i != call->end(); ++i) copy.push_back(const_cast(resp_lift(cenv, code, *i))); + + cenv.setTypeSameAs(const_cast(static_cast(copy.head)), + const_cast(static_cast(call))); - cenv.setTypeSameAs(copy, call); return copy; } @@ -234,7 +237,7 @@ resp_lift(CEnv& cenv, Code& code, const AST* ast) throw() if (sym) return lift_symbol(cenv, code, sym); - ATuple* const call = const_cast(ast->to_tuple()); + const ATuple* const call = ast->to_tuple(); if (call) { const ASymbol* const sym = call->head()->to_symbol(); const std::string form = sym ? sym->cppstr : ""; -- cgit v1.2.1