aboutsummaryrefslogtreecommitdiffstats
path: root/src/lift.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-27 17:51:29 +0000
committerDavid Robillard <d@drobilla.net>2010-12-27 17:51:29 +0000
commit0b014dee824646461b7d402bf9bbcf954ff0eba3 (patch)
tree6e9da06aad29bc641bbc04e181a32e272cc66af8 /src/lift.cpp
parent28e3727290335ee85793795f7ec6d48e050db922 (diff)
downloadresp-0b014dee824646461b7d402bf9bbcf954ff0eba3.tar.gz
resp-0b014dee824646461b7d402bf9bbcf954ff0eba3.tar.bz2
resp-0b014dee824646461b7d402bf9bbcf954ff0eba3.zip
Kill AType.
git-svn-id: http://svn.drobilla.net/resp/resp@359 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/lift.cpp')
-rw-r--r--src/lift.cpp64
1 files changed, 32 insertions, 32 deletions
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<ATuple>(sym->loc, cenv.penv.sym("."),
- cenv.penv.sym("_me"),
- new ALiteral<int32_t>(T_INT32, vars.index(sym) + 1, Cursor()),
- NULL);
+ return tup(sym->loc, cenv.penv.sym("."),
+ cenv.penv.sym("_me"),
+ new ALiteral<int32_t>(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<int32_t>* index = (ALiteral<int32_t>*)(dot->list_ref(2));
- List<ATuple, const AST> copy;
+ List copy;
copy.push_back(dot->head());
copy.push_back(resp_lift(cenv, code, dot->list_ref(1)));
copy.push_back(new ALiteral<int32_t>(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<ATuple, const AST> 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<ATuple, const AST> 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<ATuple, const AST> implProt;
- List<AType, const AType> 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<const AType>((*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<ATuple>(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<ATuple, const AST> 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<ATuple, const AST> 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<ATuple>(call->loc, cenv.penv.sym("."),
- copy.head->head(),
- new ALiteral<int32_t>(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<int32_t>(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<ATuple, const AST> copy;
+ List copy;
copy.push_back(call->head());
// Lift all arguments