From 76a2dc8afc2e59e2927cacb7270e28943ec9841d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 7 Mar 2009 02:03:33 +0000 Subject: Fancy varargs AType constructor. git-svn-id: http://svn.drobilla.net/resp/tuplr@69 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- typing.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'typing.cpp') diff --git a/typing.cpp b/typing.cpp index 5e419fd..872462a 100644 --- a/typing.cpp +++ b/typing.cpp @@ -24,7 +24,7 @@ void ASTTuple::constrain(TEnv& tenv) const { - AType* t = new AType(ASTTuple(), loc); + AType* t = new AType(loc, 0); FOREACH(const_iterator, p, *this) { (*p)->constrain(tenv); t->push_back(tenv.type(*p)); @@ -39,8 +39,7 @@ ASTClosure::constrain(TEnv& tenv) const at(2)->constrain(tenv); AType* protT = tenv.type(at(1)); AType* bodyT = tenv.type(at(2)); - tenv.constrain(this, new AType(ASTTuple( - tenv.penv.sym("Fn"), protT, bodyT, 0), loc)); + tenv.constrain(this, new AType(loc, tenv.penv.sym("Fn"), protT, bodyT, 0)); } void @@ -49,11 +48,10 @@ ASTCall::constrain(TEnv& tenv) const FOREACH(const_iterator, p, *this) (*p)->constrain(tenv); AType* retT = tenv.type(this); - AType* argsT = new AType(ASTTuple(), loc); + AType* argsT = new AType(loc, 0); for (size_t i = 1; i < size(); ++i) argsT->push_back(tenv.type(at(i))); - tenv.constrain(at(0), new AType(ASTTuple( - tenv.penv.sym("Fn"), argsT, retT, NULL), loc)); + tenv.constrain(at(0), new AType(at(0)->loc, tenv.penv.sym("Fn"), argsT, retT, 0)); } void @@ -141,7 +139,7 @@ void ASTConsCall::constrain(TEnv& tenv) const { if (size() != 3) throw Error("`cons' requires exactly 2 arguments", loc); - AType* t = new AType(ASTTuple(tenv.penv.sym("Pair"), 0), loc); + AType* t = new AType(loc, tenv.penv.sym("Pair"), 0); for (size_t i = 1; i < size(); ++i) { at(i)->constrain(tenv); t->push_back(tenv.type(at(i))); @@ -154,10 +152,10 @@ ASTCarCall::constrain(TEnv& tenv) const { if (size() != 2) throw Error("`car' requires exactly 1 argument", loc); at(1)->constrain(tenv); - AType* ct = tenv.var(loc); - AType* tt = new AType(ASTTuple(tenv.penv.sym("Pair"), ct, tenv.var(), 0), loc); - tenv.constrain(at(1), tt); - tenv.constrain(this, ct); + AType* carT = tenv.var(loc); + AType* pairT = new AType(at(1)->loc, tenv.penv.sym("Pair"), carT, tenv.var(), 0); + tenv.constrain(at(1), pairT); + tenv.constrain(this, carT); } void @@ -165,10 +163,10 @@ ASTCdrCall::constrain(TEnv& tenv) const { if (size() != 2) throw Error("`cdr' requires exactly 1 argument", loc); at(1)->constrain(tenv); - AType* ct = tenv.var(loc); - AType* tt = new AType(ASTTuple(tenv.penv.sym("Pair"), tenv.var(), ct, 0), loc); - tenv.constrain(at(1), tt); - tenv.constrain(this, ct); + AType* cdrT = tenv.var(loc); + AType* pairT = new AType(at(1)->loc, tenv.penv.sym("Pair"), tenv.var(), cdrT, 0); + tenv.constrain(at(1), pairT); + tenv.constrain(this, cdrT); } -- cgit v1.2.1