From 0b014dee824646461b7d402bf9bbcf954ff0eba3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 27 Dec 2010 17:51:29 +0000 Subject: Kill AType. git-svn-id: http://svn.drobilla.net/resp/resp@359 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/lift.cpp | 64 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/lift.cpp') diff --git a/src/lift.cpp b/src/lift.cpp index 25940f4..4b57637 100644 --- a/src/lift.cpp +++ b/src/lift.cpp @@ -46,10 +46,10 @@ lift_symbol(CEnv& cenv, Code& code, const ASymbol* sym) throw() * to the closure (the calling lift_fn will use cenv.liftStack.top() * to construct the closure after the fn body has been lifted). */ - return tup(sym->loc, cenv.penv.sym("."), - cenv.penv.sym("_me"), - new ALiteral(T_INT32, vars.index(sym) + 1, Cursor()), - NULL); + return tup(sym->loc, cenv.penv.sym("."), + cenv.penv.sym("_me"), + new ALiteral(T_INT32, vars.index(sym) + 1, Cursor()), + NULL); } } return sym; @@ -59,7 +59,7 @@ static const AST* lift_dot(CEnv& cenv, Code& code, const ATuple* dot) throw() { const ALiteral* index = (ALiteral*)(dot->list_ref(2)); - List copy; + List copy; copy.push_back(dot->head()); copy.push_back(resp_lift(cenv, code, dot->list_ref(1))); copy.push_back(new ALiteral(T_INT32, index->val + 1, Cursor())); // skip RTTI @@ -78,7 +78,7 @@ lift_def(CEnv& cenv, Code& code, const ATuple* def) throw() cenv.setName(body->as_tuple(), sym->str()); assert(def->list_ref(1)->to_symbol()); - List copy; + List copy; copy.push_back(def->head()); copy.push_back(resp_lift(cenv, code, def->list_ref(1))); for (ATuple::const_iterator t = def->iter_at(2); t != def->end(); ++t) @@ -99,7 +99,7 @@ lift_def(CEnv& cenv, Code& code, const ATuple* def) throw() static const AST* lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw() { - List impl; + List impl; impl.push_back(fn->head()); const string fnName = cenv.name(fn); @@ -113,20 +113,20 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw() // Create a new stub environment frame for parameters cenv.push(); - const AType* type = cenv.type(fn); - AType::const_iterator tp = type->prot()->begin(); + const ATuple* type = cenv.type(fn)->as_tuple(); + ATuple::const_iterator tp = type->prot()->begin(); - List implProt; - List implProtT; + List implProt; + List implProtT; // Prepend closure parameter implProt.push_back(cenv.penv.sym("_me")); for (ATuple::const_iterator p = fn->prot()->begin(); p != fn->prot()->end(); ++p) { - const AType* paramType = (*tp++)->as_type(); - if (paramType->kind == AType::EXPR && *paramType->head() == *cenv.tenv.Fn) { - const AType* fnType = new AType(cenv.tenv.var(), paramType, fnType->loc); - paramType = tup((*p)->loc, cenv.tenv.Tup, fnType, NULL); + const AST* paramType = (*tp++); + if (is_form(paramType, "Fn")) { + const ATuple* fnType = new ATuple(cenv.tenv.var(), paramType, fnType->loc); + paramType = tup((*p)->loc, cenv.tenv.Tup, fnType, NULL); } cenv.def((*p)->as_symbol(), *p, paramType, NULL); implProt.push_back(*p); @@ -136,7 +136,7 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw() impl.push_back(implProt); // Lift body - const AType* implRetT = NULL; + const AST* implRetT = NULL; for (ATuple::const_iterator i = fn->iter_at(2); i != fn->end(); ++i) { const AST* lifted = resp_lift(cenv, code, *i); impl.push_back(lifted); @@ -147,13 +147,13 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw() // Create definition for implementation fn ASymbol* implName = cenv.penv.sym(implNameStr); - ATuple* def = tup(fn->loc, cenv.penv.sym("def"), implName, impl.head, NULL); + ATuple* def = tup(fn->loc, cenv.penv.sym("def"), implName, impl.head, NULL); code.push_back(def); - TList implT; // Type of the implementation function - TList tupT(fn->loc, cenv.tenv.Tup, cenv.tenv.var(), NULL); - TList consT; - List cons(fn->loc, cenv.penv.sym("Closure"), implName, NULL); + List implT; // Type of the implementation function + List tupT(fn->loc, cenv.tenv.Tup, cenv.tenv.var(), NULL); + List consT; + List cons(fn->loc, cenv.penv.sym("Closure"), implName, NULL); const CEnv::FreeVars& freeVars = cenv.liftStack.top(); for (CEnv::FreeVars::const_iterator i = freeVars.begin(); i != freeVars.end(); ++i) { @@ -165,7 +165,7 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw() implProtT.push_front(tupT); - implT.push_back((AType*)type->head()); + implT.push_back(type->head()); implT.push_back(implProtT.head); implT.push_back(implRetT); @@ -185,7 +185,7 @@ lift_fn(CEnv& cenv, Code& code, const ATuple* fn) throw() static const AST* lift_call(CEnv& cenv, Code& code, const ATuple* call) throw() { - List copy; + List copy; // Lift all children (callee and arguments, recursively) for (ATuple::const_iterator i = call->begin(); i != call->end(); ++i) @@ -210,20 +210,20 @@ lift_call(CEnv& cenv, Code& code, const ATuple* call) throw() */ const ATuple* closure = copy.head->list_ref(0)->as_tuple(); const ASymbol* implSym = closure->list_ref(1)->as_symbol(); - const AType* implT = cenv.type(cenv.resolve(implSym)); + const ATuple* implT = cenv.type(cenv.resolve(implSym))->as_tuple(); copy.push_front(implSym); - cenv.setType(copy, implT->list_ref(2)->as_type()); + cenv.setType(copy, implT->list_ref(2)); } else { // Call to a closure, prepend code to access implementation function - ATuple* getFn = tup(call->loc, cenv.penv.sym("."), - copy.head->head(), - new ALiteral(T_INT32, 1, Cursor()), NULL); - const AType* calleeT = cenv.type(copy.head->head()); + ATuple* getFn = tup(call->loc, cenv.penv.sym("."), + copy.head->head(), + new ALiteral(T_INT32, 1, Cursor()), NULL); + const ATuple* calleeT = cenv.type(copy.head->head())->as_tuple(); assert(**calleeT->begin() == *cenv.tenv.Tup); - const AType* implT = calleeT->list_ref(1)->as_type(); + const ATuple* implT = calleeT->list_ref(1)->as_tuple(); copy.push_front(getFn); cenv.setType(getFn, implT); - cenv.setType(copy, implT->list_ref(2)->as_type()); + cenv.setType(copy, implT->list_ref(2)); } return copy; @@ -232,7 +232,7 @@ lift_call(CEnv& cenv, Code& code, const ATuple* call) throw() static const AST* lift_args(CEnv& cenv, Code& code, const ATuple* call) throw() { - List copy; + List copy; copy.push_back(call->head()); // Lift all arguments -- cgit v1.2.1