diff options
author | David Robillard <d@drobilla.net> | 2009-03-07 02:03:33 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-03-07 02:03:33 +0000 |
commit | 76a2dc8afc2e59e2927cacb7270e28943ec9841d (patch) | |
tree | 014c7f15ad4cb9609e9466271e0f23cf0555f345 /typing.cpp | |
parent | d2c34198db88c8ffdf9a9352825a71c85a00c26e (diff) | |
download | resp-76a2dc8afc2e59e2927cacb7270e28943ec9841d.tar.gz resp-76a2dc8afc2e59e2927cacb7270e28943ec9841d.tar.bz2 resp-76a2dc8afc2e59e2927cacb7270e28943ec9841d.zip |
Fancy varargs AType constructor.
git-svn-id: http://svn.drobilla.net/resp/tuplr@69 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'typing.cpp')
-rw-r--r-- | typing.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -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); } |